I need to build a JSON string, something like this:
[
{ 'id': 1, 'name': 'John'},
{ 'id': 2, 'name': 'Dani'}
]
val jArray = JsArray();
jArray += (("id", "1"), ("name", "John"))
jArray += (("id", "2"), ("name", "Dani"))
println(jArray.dump)
I need to be able to add rows to the jArray
, something like jArray += ...
What is the closest library/solution to this?
Unfortunately writing a JSON library is the Scala community's version of coding a todo list app.
There are quite a variety of alternatives. I list them in no particular order, with notes:
💣 = has not fixed security vulnerabilities, § = has Scalaz integration, ± = supports interop with Jackson JsonNode
In Snowplow we use json4s with the Jackson back-end; we've had good experiences with Argonaut too.