In our day to day JSON usage, the JSON is usually used as an object with string
key and various value type pairs, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 { "squadName" : "Super hero squad" , "homeTown" : "Metro City" , "formed" : 2016 , "secretBase" : "Super tower" , "active" : true , "members" : [ { "name" : "Molecule Man" , "age" : 29 , "secretIdentity" : "Dan Jukes" , "powers" : [ "Radiation resistance" , "Turning tiny" , "Radiation blast" ] } , { "name" : "Madame Uppercut" , "age" : 39 , "secretIdentity" : "Jane Wilson" , "powers" : [ "Million tonne punch" , "Damage resistance" , "Superhuman reflexes" ] } , { "name" : "Eternal Flame" , "age" : 1000000 , "secretIdentity" : "Unknown" , "powers" : [ "Immortality" , "Heat Immunity" , "Inferno" , "Teleportation" , "Interdimensional travel" ] } ] }
The JSON can also made out of arrays:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [ { "name" : "Molecule Man" , "age" : 29 , "secretIdentity" : "Dan Jukes" , "powers" : [ "Radiation resistance" , "Turning tiny" , "Radiation blast" ] } , { "name" : "Madame Uppercut" , "age" : 39 , "secretIdentity" : "Jane Wilson" , "powers" : [ "Million tonne punch" , "Damage resistance" , "Superhuman reflexes" ] } ]
And JSON can actually take the form of any data type that is valid for
inclusion inside JSON, not just arrays or objects. So for example, a single string or
number would be valid JSON (reference ).
Single number or string JSON:
You can validate them in the online formetter .