Problem
如果字段是嵌套的,如何将字段添加到Json对象?
这与这个论坛类似:Adding field to a JSON using Circe
但不是:
{
ExistingField: {},
"Newfield" : {}
}
我的最终目标是:
{
ExistingField: {},
"A" : {
"B" : {
"C" : "myStringValue"
}
},
"AA" : {
"BB" : "myStringValue"
}
}
Tried
I have a list of nested fields of type String that I would like to iterate through and add.
Instead of them being nested, I just got:
{
ExistingField: {},
"A.B.C" : "myStringValue"
}
我的字段列表如下:
val listOfFields: List[String] = List("A.B.C", "AA.BB")
编辑:如果添加的字段是数组怎么办?例如:
{
ExistingField: {},
"A" : {
"B" : {
"C" : "myStringValue"
}
},
"AA" : {
"BB" : [
{
"CC": "myStringValue"
},
{
"CC": "myStringValue"
}
]
}
}