Node 12
I have the following JSON string (used as filters for database searches)
{"$and":[{"txnType":{"$in":["Cash Expense"]}}]}
I want that ugly string to look like this so I can display it to the front end:
txnType="Cash Expense"
Here is my method:
function prettyupFilters(uglyFilters){
let filters
filters = uglyFilters
.replace(/{/g,'').replace(/}/g,'')
.replace('$$and','').replace('$$in', '=')
.replace(/[/g,'').replace(/]/g,'')
.replace(/:/g,'').replace(/:/g,'')
return filters
}
But, this produces:
"$nd"["txnTy""$in"["Csh Exns"]]
How do i tweak my code to replace characters in my string to achieve my desired output? Thanks