Serialization is a process of converting Object into Raw data.In javascript many times we need to convert Raw data into Object and viceversa.
For example, when we submit a form, Its data needs to be sent to the server in JSON form.
Certain framework provides method to convert Model, Form data into JSON.
For eg backbone.js provieds following
Once we have JSON library we can use the two most useful methods whcih are availble:
For example, when we submit a form, Its data needs to be sent to the server in JSON form.
- Serialization is the process of turning any object into a string.
- De-serialization turns that string back into a native object.
Certain framework provides method to convert Model, Form data into JSON.
For eg backbone.js provieds following
Model.toJSON
for serializationModel.parse
for de-serialization
Once we have JSON library we can use the two most useful methods whcih are availble:
- JSON.stringify(obj) — converts an JavaScript object to a JSON string
- JSON.parse(str) — converts a JSON string back to a JavaScript object