0

I get data from REST API. I need to do a few request and concat array from each request into one Json.

//getting body of response

val json = parse(body)

val data = json \ "data"

//...

//... other request of data

val json_other = parse(body_other)

val data_other = json \ "data"

Both data and data_other are JArray values.

How can I concat them in one JArray?

  • 1
    data ++ data_other ... should work – Emiliano Martinez Feb 24 '22 at 09:33
  • Looks like it. And in general, the `++` operation seems to be defined on the more generic `JValue` like this: https://github.com/json4s/json4s/blob/6acb70317606800ec02751eafdc45a1e0bda5dd6/ast/shared/src/main/scala/org/json4s/JValue.scala#L61-L80 – stefanobaghino Feb 24 '22 at 10:52
  • BEWARE: [json4s is vulnerable under DoS/DoW attacks!](https://github.com/json4s/json4s/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+denial) – Andriy Plokhotnyuk Jul 04 '22 at 08:34

0 Answers0