I have checked most of the posted questions, but what I am doing now is to check if JSON is empty. However, after debugging with Chrome, the JSON object contains only "[]" and is not empty. So if there is a case where JSON doesn't have value, but a "[]", how can we check if it is empty then (which aparently it is)?
Asked
Active
Viewed 135 times
0
-
What do you mean by «JSON does not have value»? – Alexey Ten Dec 29 '14 at 08:41
-
possible duplicate of [How do you check for an empty string in JavaScript?](http://stackoverflow.com/questions/154059/how-do-you-check-for-an-empty-string-in-javascript) – Khiem-Kim Ho Xuan Dec 29 '14 at 08:44
-
possible duplicate of [Check if a JSON array is empty](http://stackoverflow.com/questions/18396073/check-if-a-json-array-is-empty) – Aditya Dec 29 '14 at 08:44
3 Answers
4
JSON is an abbreviation for JavaScript Object Notation. An empty object is []. This makes it possible to set values in that object, which would be impossible if it would have been empty.

Pieter De Clercq
- 1,951
- 1
- 17
- 29
1
Example:
{"ABC":[ "test":"test1", "test2":"test2", ]}
then U can Check it as Key.length or other length of array function and perform check
if(ABC.length>0) then ..
For JavaScript Key.length works...

Parth Trivedi
- 3,802
- 1
- 20
- 40