Showing results for 
Search instead for 
Did you mean: 

Generating wrong Json format for empty values

New Contributor

Hi All,

I am creating a Json file by using the Json formatter but I am not getting the json in correct format for all the empty values.

Below is the input for Json Formatter :


Getting below output from Json Formatter.

The output should look like below. Empty fields should be enclosed in double codes.
“Bankgroup” : “”,
“BankNumber” : “”,

Please let me know how we can achieve this.



Former Employee

Hi Mohit!
What you might try is passing that JSON over to a mapper, and using the mapper to do what you want.
Turn off pass through in the mapper and use an expression language statement to convert everything to a string like this:

$.mapValues(x=>x == null ? "" : x.toString())

This will essentially set everything to a string, even an empty string.
Here’s what my mapper looks like to do this:
Hope that gets you closer!
– David

@djsiegel I am not using the pass through. I am just mapping the fields in mapper snap and then sending it to Json formatter snap to generate the Json but it is only showing single quotation mark for empty values.

I tried your expression as well but it is also not working.


Mohit, this is just an odd bug in the Designer’s viewer for JSON preview data. If you actually save the output of the JSON Formatter to a file using a File Writer, you’ll see that the empty string is a pair of double quotes as you expect.

Can confirm, Patrick - I happened to just be building an example to test myself.
When I download it, I do see the doublequotes.
Mohit - here’s my example, with both the input and output. Hope that helps. (4.3 KB)