标签:style blog http color strong cti
官方地址:http://dojotoolkit.org/reference-guide/1.10/dojo/json.html#dojo-json
require(["dojo/json", "dojo/dom", "dojo/on", "dojo/domReady!"],
function(JSON, dom, on){
on(dom.byId("convert"), "click", function(){
var origin = ‘{"hello": "world"}‘;
var obj = JSON.parse(origin);
obj.hello = "Dojo";
obj.something = "New";
var output = JSON.stringify(obj);
dom.byId("output").innerHTML = output;
});
});
<button type="button" id="convert">Convert!</button>
<p><strong>Original JSON</strong></p>
<pre>{"hello": "world"}</pre>
<p><strong>Converted JSON</strong></p>
<pre id="output"></pre>
parse():把json字符串,转化成json对象。
stringify():把对象转化成字符串。
dojo 官方翻译 dojo/json 版本1.10,布布扣,bubuko.com
标签:style blog http color strong cti
原文地址:http://www.cnblogs.com/tiandi/p/3829911.html