官方地址: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
时间: 2024-12-31 04:25:15