Skip to content

JSON

IT Notes → Javascript @ December 22, 2020

  • The object literal notation of JavaScript.
  • var myJSONObject = {key1: value1, key2: value2, key3:
    
    [{key4: value4, key5: value5},
    
    {key4: value6, key5: value7},
    
    {key4: value8, key5: value9},
    
    ]};
  • myJSONObject.key3 [0].key5               //value5
  • var myObject = eval(‘(‘ + myJSONtext + ‘)’);
  • var myObject = JSON.parse(myJSONtext, reviver);

JSON versus Eval:

  • security issues.
  • faster.

JSON does not support cyclic data structures.

  • typeof value  //To get typeof.
  • var myJSONText = JSON.stringify(myObject, replacer);

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x