Class JSON strings are merged according to hierarchical relationships

known to have two hierarchical relationships of JSON-like strings, can not be converted into objects, how to get them to merge.

the code is as follows:

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 })
    })
  })
}"

you can see the anotherList in str1 and the otherList in str2

expect the following results

"{
  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
        })
      })
    })
  }
}"
Jun.28,2022
Menu