I'm using scala and Json4s to add a JValue to a JArray in a loop, this way:
var recordsJArray = JArray
for (record <- recordsList) {
val mrecord= new com.google.gson.Gson().toJson(record.asMap())
val jsonRecord = parse(mrecord)
recordsJArray = recordsJArray.++jsonRecord
}
I've searched de api: https://static.javadoc.io/org.json4s/json4s-core_2.9.1/3.0.0/org/json4s/JsonAST$$JArray.html
and I've tried to use the method:
def ++ (other: JValue): JValue
But it's not working.
error: value ++ is not a member of object org.json4s.JsonAST.JArray
[ERROR] recordsJArray = recordsJArray++jsonRecord
Can someone please help me? Is there any way of adding the JValue to the JArray? Thank you