dojo.toJson

<!DOCTYPE HTML>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Demo</title>
		<script src="dojo16/dojo/dojo.js"
		data-dojo-config="async: true, parseOnLoad: true,isDebug:true"></script>
		</link>
		<script type = "text/javascript">
			var obj = {a:1, b:2,c:3};
			var  result = dojo.toJson(obj, true);
			console.log(result);
			
			var obj2 = {a1:'hello', b1 :'world'};
			var result2 = dojo.toJson(obj2, true);
			console.log(result2);
						
		</script>
	</head>
	<body>
		<div id = "test">hello</div>
	</body>
</html>

    运行结果:

 

{
	"a": 1, 
	"b": 2, 
	"c": 3
}
{
	"a1": "hello", 
	"b1": "world"
}
//dojo.toJson(/*Object*/ json, /*Boolean*/ prettyPrint) 是否美化

你可能感兴趣的:(json)