The use of JS to the JSON data processing, the project encountered the need for JSON data related operations, such as additions and deletions to the operation, this thought will be more difficult, online search, found or relatively simple, paste a piece of code:
<script type= "Text/javascript" >
var json = {
"age": "
Name": "CST"
};
Modify the age value in JSON because there is an age attribute in JSON
json["age" = =;
alert (json.age);
Add the sex value in JSON because there is no sex attribute
json["sex" = "M" in JSON;
alert (json.sex); M
<!--traverse JSON data--> for
(Var key in JSON) {
try{
var value = eval ("json[" + key + "']");
alert (key+ "_" +value);
} catch (e) {}
}
//Delete age attribute in JSON data
delete json["age"];
alert (json.age); Undefined
</script>
The above JavaScript to the JSON to delete and modify the attribute is small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.