标签:script i++ 字符串 gif ons ext var ring parse
// jquery的方法 var jsonObj = $.parseJSON(jsonStr) //js 的方法 var jsonObj = JSON.parse(jsonStr)
//js方法 var jsonStr1 = JSON.stringify(jsonObj)
示例:
<script type="text/javascript"> var jsonStr = ‘[{"id":"01","open":false,"pId":"0","name":"A部门"},{"id":"01","open":false,"pId":"0","name":"A部门"},{"id":"011","open":false,"pId":"01","name":"A部门"},{"id":"03","open":false,"pId":"0","name":"A部门"},{"id":"04","open":false,"pId":"0","name":"A部门"}, {"id":"05","open":false,"pId":"0","name":"A部门"}, {"id":"06","open":false,"pId":"0","name":"A部门"}]‘; // var jsonObj = $.parseJSON(jsonStr); var jsonObj = JSON.parse(jsonStr) console.log(jsonObj) var jsonStr1 = JSON.stringify(jsonObj) console.log(jsonStr1+"jsonStr1") </script>
<script type="text/javascript"> var jsonStr = ‘[{"id":"01","open":false,"pId":"0","name":"A部门"},{"id":"01","open":false,"pId":"0","name":"A部门"},{"id":"011","open":false,"pId":"01","name":"A部门"},{"id":"03","open":false,"pId":"0","name":"A部门"},{"id":"04","open":false,"pId":"0","name":"A部门"}, {"id":"05","open":false,"pId":"0","name":"A部门"}, {"id":"06","open":false,"pId":"0","name":"A部门"}]‘; // var jsonObj = $.parseJSON(jsonStr); var jsonObj = JSON.parse(jsonStr) console.log(jsonObj) var jsonStr1 = JSON.stringify(jsonObj) console.log(jsonStr1+"jsonStr1") var jsonArr = []; for(var i =0 ;i < jsonObj.length;i++){ jsonArr[i] = jsonObj[i]; } console.log(typeof(jsonArr)) </script>
标签:script i++ 字符串 gif ons ext var ring parse
原文地址:https://www.cnblogs.com/firstcsharp/p/9154985.html