已知有两有层级关系的类似JSON的字符串,无法转成对象,怎么让他们合并。
代码如下:
var str1 = "data : {
item : ( payload.data.list map(value0, index0) -> {
gradeList : ( value0.gradeList map(value1, index1) -> {
otherList : ( value1.otherList map(value2, index2) -> {
anotherList : ( value2.anotherList map(value3, index3) -> { name: value3.name })
})
})
})
}"
var str2 = "data : {
item : ( payload.data.list map(value0, index0) -> {
gradeList : ( value0.gradeList map(value1, index1) -> {
otherList : ( value1.otherList map(value2, index2) -> { name: value2.name })
})
})
}"
可以看出str1中的anotherList,在str2中的otherList里面
希望得到如下结果
"{
data: {
list: (payload.data.list map (value0, index0) -> {
gradeList: (value0.gradeList map (value1, index1) -> {
otherList: (value1.otherList map (value2, index2) -> {
anotherList: (value2.anotherList map (value3, index3) -> {
name: value3.name
}),
name: value2.name
})
})
})
}
}"