Monday, November 18, 2019

Define stringifyJSON & ParseJSON

So we shall start with JSON.stringify().

It's a function that converts an object or an array into strings in the case of the object it puts the entire object in between quotations and puts the keys of the object inside quotes as well and if there is an empty string, a function or a undefined it returns null this works with arrays too.



for arrays is much simpler it puts the whole array inside quotes and changes the numbers inside into strings.

in conclusion it adds the object or an array into a json string



as for JSON.parse it acts as the opposite of JSON.stringify() it changes the object from json string to a normal object or an array



Sofian Saleh

No comments:

Post a Comment