JSON has serialization and deserialization
Serialization (converted to String type): Json.stringify (JSON)
Deserialization (converted to object type): Json.parse (JSON)
When you need to return a JSON object and modify the value in the JSON to use this method,
function Modifycolor (x, y) {
var colors = []
The JSON object can hold functions, you can use the function to modify the data in the JSON object, and input if you do not need to use the JSON object function, you can use serialization, and then deserialization, the function will be eliminated
Lost.
var Jsona = {' x ': x, ' y ': y, ' color ': colors}
This.addcolor = function (value) {
Colors.push (value)
}
Console.log (Jsona)
Return Jsona
}
In this case, the JSON object returned by the previous function will not have a function.
function Color (JSON) {
The JSON object to be passed in
Console.log (JSON)
}
JSON alternative use