What’s the difference between stringifyJSON and parseJSON?

Firas Bchir
1 min readJul 27, 2020

--

so first we all need to understand that the JSON is kind of a type or a form that we use it in special cases and to store Data in special places like the localStorage…, so both of stringifyJSON and parseJSON are responsible for transforming the type of the Data that we want to store.

Let’s start with stringifyJSON: which will transform the Data from it’s normal form to JSON form for example we have an object like this :

var obj = {a : 1 , b : 2}; when we Do JSON.stringify({a : 1 , b : 2}) the object will became like“{“a”:1,”b”:2}”

now the object is already in JSON form whenever we want to use this object again what we need to do ?

of course we need to call it from the place it was stored in but will be in JSON form so we need to use JSON.parse(obj) to transform it back to it’s normal shape, aaaaand that’s it.

--

--