Variables used in JSON files
JSON standard is a subset of JavaScript language and thus supports similar variable types
Binary values – boolean type
Boolean expression has one of two values: true or false (which are sometimes represented as integers 1 and 0, respectively). Although it is a simple enough data type, many unexpected errors may arise due to fact that JSON interprets as true the following non-boolean values:
-
any non-zero number type, for example, values 1, -50, or 3.41
-
any non-empty text type, for example “text” , “00”, or even string of value “false”.
-
binary value true
Boolean values false is also given to such values as:
-
number 0
-
number -0 (has no meaning and is resolved to 0)
-
empty text value (“”)
-
any declared variable without any value
-
value null
-
binary value false
-
non-numerical value NaN (for values that cannot be represented as numbers)
-
Number type – number, integer
Both types are similar to each other. Integer type is given to integer number values. Number type is given to floating-point numbers and is a dynamic type. Converting number type to integer type implies loss of precision.
-
Character string type – string
String is a sequence of zero or more unicode characters, which follows that an empty string value (“” ) is as string of length 0.
-
Array type – array
Array is a list of zero or more values of single type, for example, an array containing the names of days of the week.
-
Object type – object
Objects can hold any types of data.
-
Value null
Value null is not a separate data type, but indicates absence of any value. It is an accepted convention to use null to represent no object value.