How to render JArray without square parentheses into JSON?

35 Views Asked by At

When I render JArray object:

val json = compact(render(data))

I get JSON like that:

[
{object},
{object}
]

But I need to get next text data:

{object},
{object}

In other words, I need to get string without "open and end" square parentheses.

Is there any way to do that without go thought all elements and render each of them separately?

1

There are 1 best solutions below

0
Alexander Lopatin On

At the moment I have found such a solution:

val json = compact(render(data))
val parentheses = "^\\[|\\]$".r
parentheses.replaceAllIn(json, "")