trait JsonAdapter[T] extends JsonInput[T] with JsonOutput[T]
Consolidates JsonInput and JsonOutput.
import javax.json.{ JsonObject, JsonValue } import little.json.{ Json, JsonAdapter } import little.json.Implicits._ case class User(id: Int, name: String) implicit object UserAdapter extends JsonAdapter[User] { // Define how to read User from JsonValue def reading(json: JsonValue): User = json.asInstanceOf[JsonObject] match { case obj => User(obj.getInt("id"), obj.getString("name")) } // Define how to write User to JsonValue def writing(user: User): JsonValue = Json.obj("id" -> user.id, "name" -> user.name) } // Write User to JsonValue val json = Json.toJson(User(0, "root")) // Read User from JsonValue val user = json.as[User]
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- JsonAdapter
- JsonOutput
- ContextWriter
- ObjectContextWriter
- ArrayContextWriter
- BuilderCompanion
- ObjectBuilderCompanion
- ArrayBuilderCompanion
- JsonInput
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Abstract Value Members
-
abstract
def
reading(json: JsonValue): T
Converts JsonValue to T value.
Converts JsonValue to T value.
- Definition Classes
- JsonInput
-
abstract
def
writing(value: T): JsonValue
Converts T value to JsonValue.
Converts T value to JsonValue.
- Definition Classes
- JsonOutput
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
add(name: String, value: T)(implicit builder: JsonObjectBuilder): JsonObjectBuilder
Converts T value to JsonValue and adds it to object builder.
Converts T value to JsonValue and adds it to object builder.
- Definition Classes
- JsonOutput → ObjectBuilderCompanion
-
def
add(value: T)(implicit builder: JsonArrayBuilder): JsonArrayBuilder
Converts T value to JsonValue and adds it to array builder.
Converts T value to JsonValue and adds it to array builder.
- Definition Classes
- JsonOutput → ArrayBuilderCompanion
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
write(name: String, value: T)(implicit generator: JsonGenerator): JsonGenerator
Converts T value to JsonValue and writes it to object context.
Converts T value to JsonValue and writes it to object context.
- Definition Classes
- JsonOutput → ObjectContextWriter
-
def
write(value: T)(implicit generator: JsonGenerator): JsonGenerator
Converts T value to JsonValue and writes it to array context.
Converts T value to JsonValue and writes it to array context.
- Definition Classes
- JsonOutput → ArrayContextWriter