Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://jackson.codehaus.org/" rel="noreferrer">Jackson</a> is a Java library to process JSON fast. The Jerkson project wraps Jackson, but appears to be abandoned. I've switched to Jackson's <a href="https://github.com/FasterXML/jackson-module-scala" rel="noreferrer">Scala Module</a> for serialization and deserialization to native Scala data structures.</p> <p>To get it, include the following in your <code>build.sbt</code>:</p> <pre><code>libraryDependencies ++= Seq( "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.1.3", ... ) </code></pre> <p>Then your examples will work verbatim with the following Jackson wrapper (I extracted it from jackson-module-scala test files):</p> <pre><code>import java.lang.reflect.{Type, ParameterizedType} import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.scala.DefaultScalaModule import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.`type`.TypeReference; object JacksonWrapper { val mapper = new ObjectMapper() mapper.registerModule(DefaultScalaModule) def serialize(value: Any): String = { import java.io.StringWriter val writer = new StringWriter() mapper.writeValue(writer, value) writer.toString } def deserialize[T: Manifest](value: String) : T = mapper.readValue(value, typeReference[T]) private [this] def typeReference[T: Manifest] = new TypeReference[T] { override def getType = typeFromManifest(manifest[T]) } private [this] def typeFromManifest(m: Manifest[_]): Type = { if (m.typeArguments.isEmpty) { m.erasure } else new ParameterizedType { def getRawType = m.erasure def getActualTypeArguments = m.typeArguments.map(typeFromManifest).toArray def getOwnerType = null } } } </code></pre> <p>Other Scala 2.10 JSON options include Twitter's <a href="https://github.com/stevej/scala-json" rel="noreferrer">scala-json</a> based on the Programming Scala book--it's simple, at the cost of performance. There is also <a href="https://github.com/spray/spray-json" rel="noreferrer">spray-json</a>, which uses <a href="https://github.com/sirthias/parboiled/wiki" rel="noreferrer">parboiled</a> for parsing. Finally, <a href="http://mandubian.com/2012/11/11/JSON-inception/" rel="noreferrer">Play's JSON handling</a> looks nice, but it does not easily decouple from the Play project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload