airfame-json is a pure-Scala json parser.


Maven Central

libraryDependencies += "org.wvlet.airframe" %% "airframe-json" % "(version)"

Parsing JSON

import wvlet.airframe.json.JSON

// Returns a JSON value object of the input JSON string 
val jsonValue = JSON.parse("""{"id":1, "name":"leo"}""")

Mapping JSON into object

With airframe-codec, it supports JSON to object mapping.

Add airframe-codec to your dependency:

libraryDependencies += "org.wvlet.airframe" %% "airframe-codec" % "(version)"

MessageCodec will create a JSON encoder and decorder for your objects:

import wvlet.airframe.codec.MessageCodec

case class Person(id:Int, name:String)

val p = Person(1, "leo")

val codec = MessageCodec.of[Person]
// Convert the object to JSON representation
val json = codec.toJson(p) // {"id":1, "name":"leo"}

// Read JSON as case class 
codec.unpackJson(json) // Some(Person(1, "leo"))