JSON parse, braces for empty fields

You must Login before you can answer or comment on any questions.

I have an object in the response string which has empty/null/blank fields like field2 below:

obj {
    "field1": "somevalue",
    "field2": {}
}
when JSON.parsed(obj), obj.field2 gives "{}" instead of blank.

I'd want to get a blank string instead of the braces. Any suggestions to deal with this are most welcome. Thanks in advance.

1 Answer

obj {
    "field1": "somevalue",
    "field2": ""
}

— answered 12 months ago by Rainer Schleevoigt
answer permalink
1 Comment
  • @Rainer, many thanks for the instant response. It seems so simple after you answered this. My server side php code while stringifying is returning "{}" for a blank string instead of "". So I guess I need to fix that. Appreciate much!!

    — commented 12 months ago by Apoorva Singh

Your Answer

Think you can help? Login to answer this question!