Reputation: 13
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!!
Upvotes: 1
Views: 101
Reputation: 4515
In JSON, an object is defined with { }
, which is exactly what you would represent an empty object as.
{
"result": [
{
"a": "1",
"b": {
"c1": "31",
"c2": "32"
}
}, {
"a": "5",
"b": { }
}
]
}
Upvotes: 0
Reputation: 816472
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.
Upvotes: 3