Simple wrapper for json4s to simplify de/serialization of JSON.
import onema.json.Extensions._
case class TestJsonFoo(name: String, value: String, id: Int = 0)
val fooJson = "{\"name\": \"test\", \"value\": \"foo\"}"
val fooObject = fooJson.jsonDecode[TestJsonFoo]
fooObject.name should be("test")
fooObject.value should be("foo")
fooObject.id should be(0)
import onema.json.Extensions._
case class Message(data: Seq[String])
val result = "{\"data\":[\"http://foo.com\",\"http://bar.com\",\"http://baz.com\",\"http://blah.org\"]}"
val message = Message(Seq("http://foo.com", "http://bar.com", "http://baz.com", "http://blah.org"))
val jsonValue = message.asJson
jsonValue should be(result)
import onema.json.JavaExtensions._
val fooJson = "{\"name\": \"test\", \"value\": \"foo\"}"
val fooObject = fooJson.jsonDecode[TestJsonPojo]
fooObject.getName should be("test")
fooObject.getValue should be("foo")
fooObject.getId should be(0)
import onema.json.JavaExtensions._
val result = "{\"data\":[\"http://foo.com\",\"http://bar.com\",\"http://baz.com\",\"http://blah.org\"]}"
val message = new TestJsonPojo()
val jsonValue = message.asJson
jsonValue should be(result)