Json format strings and arrays which are interconvertible

json format string and an array of data formats are the same, but did not refer to the same time on the browser used to view the console.
json format string

{"id":10001,"parent":"#","text":"实例1","state":{"selected":true}},
{"id":10002,"parent":"#","text":"实例2","state":{"selected":false}},
{"id":10003,"parent":10002,"text":"实例3","state":{"selected":false}},
{"id":10004,"parent":10003,"text":"实例4","state":{"selected":false}},
{"id":10005,"parent":10003,"text":"实例5","state":{"selected":false}},
{"id":10006,"parent":10003,"text":"实例6","state":{"selected":false}},
{"id":10007,"parent":10003,"text":"实例7","state":{"selected":false}},

An array of json format

0
   id :10001
   parent : #
   text : 实例1
   state : 
              selected :true
1
   id :10002
   parent : #
   text : 实例2
   state : 
              selected :true
2
   id :10003
   parent : 10002
   text : 实例3
   state : 
              selected :true
......

arr array, str string.
jzson transfer array format string
var str = JSON.stringify (arr);
string array jzson transfer format
var ARR = the JSON.parse (STR);
PS: can this.roleaddlist = JSON.parse (this.arr. data);
strings arr array data corresponding to the key array.
An array of selected partial conversion.

Guess you like

Origin blog.csdn.net/weixin_44724060/article/details/88264972
Recommended