Home  >  Article  >  Web Front-end  >  Share examples of JS serialization and deserialization of json

Share examples of JS serialization and deserialization of json

零下一度
零下一度Original
2017-06-15 13:14:301349browse

This article mainly introduces the serialization and deserialization functions of json implemented by JS, and analyzes the related implementation techniques of javascript for json serialization and deserialization in the form of specific examples. Friends in need can refer to it

The example of this article tells the serialization of JS to implement JSON. Share it with you for your reference, as follows:

Series serialization:


var s = new Object();
s.Name = "clientValue";
s.Id = 1;
s.ClassId = 2;
var data = JSON.stringify(s);
console.log(data);

## Eval turning the string into the object


Complete example:

## Run the renderings as follows:


##

The above is the detailed content of Share examples of JS serialization and deserialization of json. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn