"location" : null // this is not really an array it's a null object
"location" : [] // this is an empty array
It looks like this API returns null when there is no location defined - instead of returning an empty array, not too unusual really - but they should tell you if they're going to do this.
Answer from Matt Varblow on Stack Overflow"location" : null // this is not really an array it's a null object
"location" : [] // this is an empty array
It looks like this API returns null when there is no location defined - instead of returning an empty array, not too unusual really - but they should tell you if they're going to do this.
null is a legal value (and reserved word) in JSON, but some environments do not have a "NULL" object (as opposed to a NULL value) and hence cannot accurately represent the JSON null. So they will sometimes represent it as an empty array.
Whether null is a legal value in that particular element of that particular API is entirely up to the API designer.
JavaScript- Create an empty json array - Stack Overflow
Best Practices to send for Empty Values of a JSON API?
How to send a empty array to JSON request to the API? | OutSystems
An empty array in JSON configuration file results in a null value in the configuration object
Assuming to be placed in a variable, because you have 'json' tagged. The following is some explanation of each step of a simple example breakdown:
// create an empty array
var array = [];
// create an object with properties "id", "action" with mock values
var object = {
id: "1",
action: "shout"
}
// add object to array
array.push(object);
// create encode json string
var myJSONString = JSON.stringify(array);
Hope this helps.
Do you mean this?
JSON.stringify({
id: null,
action: null
})
What do you choose? Getting lots of conflicting answers.
-
Null
-
Undefined (Omitted from JSON)
-
Empty of that type?
-
String = ""
-
Number = 0
-
Boolean = false
-
Array = []
-
Object = {}
-
CMS JSON API to be consumed by JS Framework Frontend