Bhavita Jaiswal Bhavita Jaiswal - 28 days ago 5
JSON Question

Whats the standard of defining an empty object in JSON

I have an issue with my application. It is returning a JSON file of an array of objects. The application is defining an empty object inside the array of objects as text value string whose value is defined as an object in the other element of array. Please see the value of the key "b" in the example.

For Eg:

"result": [{
"a": "1",
"b": {
"c1": "31",
"c2": "32"
}, {
"a": "5",
"b": ""



I want to know if that is a correct way of defining the key "b" as an empty object.

Thanks in advance!!


An empty object is defined by {}:

"b": {}

I.e. use the usual object delimiters but don't add any key-values.

What you defined is an empty string.