json object is converted to string and the implementation method of encryption and decryption when it is passed as a parameter

  • 2021-07-01 06:21:05
  • OfStack

"son Object Strings Interchange"

For example, I have two variables. I want to convert a to a string and b to an JSON object:


var a={"name":"tom","sex":" Male ","age":"24"};

var b='{"name":"Mike","sex":" Female ","age":"29"}';

stringify () and parse () methods of JSON objects can be directly used in advanced browsers such as Firefox, chrome, opera, safari, ie9 and ie8.

JSON. stringify (obj) Converts JSON to a string.

JSON. parse (string) converts the string to JSON format;

The above transformation can be written as follows:


var a={"name":"tom","sex":" Male ","age":"24"};
 
var b='{"name":"Mike","sex":" Female ","age":"29"}';
 
var aToStr=JSON.stringify(a);
 
var bToObj=JSON.parse(b);
 
alert(typeof(aToStr)); //string
 
alert(typeof(bToObj));//object

[Encryption and Decryption]

Only escape () unescape () is used for the time being

Update when other encryption and decryption methods encounter


Related articles: