Use JSON.parse, JSON.stringify to deep clone json objects

parse() is used to parse a json object (character to object) from a string.
Note: single quotes are written outside {}, each attribute name must be double quoted, otherwise an exception will be thrown

// 正确用法
JSON.parse('{"aa":11}')

// 报错
JSON.parse('{aa:11}')

stringify() is used to parse a string from an object (object to character)



Use JSON.parse(JSON.stringify()) to clone json objects in depth

var dataEdit = JSON.parse(JSON.stringify(data))

//end

Guess you like

Origin blog.csdn.net/u013970232/article/details/111207010