object Json
Provides factory methods and other utilities.
import javax.json.JsonObject import little.json.{ Json, JsonInput, JsonOutput } import little.json.Implicits._ case class User(id: Int, name: String) // Define how to read User from JsonValue implicit val userJsonInput: JsonInput[User] = { case json: JsonObject => User(json.getInt("id"), json.getString("name")) case json => throw new IllegalArgumentException("JsonObject required") } // Define how to write User to JsonValue implicit val userJsonOutput: JsonOutput[User] = { user => Json.obj("id" -> user.id, "name" -> user.name) } // Parse String to JsonValue val json = Json.parse("""{ "id": 0, "name": "root" }""") // Read User from JsonValue val user = json.as[User] // Write User to JsonValue val jsonToo = Json.toJson(user)
- Alphabetic
- By Inheritance
- Json
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
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
arr(values: JsonValue*): JsonArray
Creates JsonArray from list of values.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
createArrayBuilder(): JsonArrayBuilder
Creates JsonArrayBuilder.
-
def
createGenerator(writer: Writer, prettyPrinting: Boolean): JsonGenerator
Creates JsonGenerator with given writer.
Creates JsonGenerator with given writer.
- writer
writer to which JSON is written
- prettyPrinting
specifies whether JSON output should be beautified
-
def
createGenerator(writer: Writer): JsonGenerator
Creates JsonGenerator with given writer.
-
def
createGenerator(out: OutputStream, prettyPrinting: Boolean): JsonGenerator
Creates JsonGenerator with given output stream.
Creates JsonGenerator with given output stream.
- out
output stream to which JSON is written
- prettyPrinting
specifies whether JSON output should be beautified
-
def
createGenerator(out: OutputStream): JsonGenerator
Creates JsonGenerator with given output stream.
-
def
createObjectBuilder(): JsonObjectBuilder
Creates JsonObjectBuilder.
-
def
createParser(reader: Reader): JsonParser
Creates JsonParser with given reader.
-
def
createParser(in: InputStream): JsonParser
Creates JsonParser with given input stream.
-
def
createReader(reader: Reader): JsonReader
Creates JsonReader with given reader.
-
def
createReader(in: InputStream): JsonReader
Creates JsonReader with given input stream.
-
def
createWriter(writer: Writer, prettyPrinting: Boolean): JsonWriter
Creates JsonWriter with given writer.
Creates JsonWriter with given writer.
- writer
writer to which JSON is written
- prettyPrinting
specifies whether JSON output should be beautified
-
def
createWriter(writer: Writer): JsonWriter
Creates JsonWriter with given writer.
-
def
createWriter(out: OutputStream, prettyPrinting: Boolean): JsonWriter
Creates JsonWriter with given output stream.
Creates JsonWriter with given output stream.
- out
output stream to which JSON is written
- prettyPrinting
specifies whether JSON output should be beautified
-
def
createWriter(out: OutputStream): JsonWriter
Creates JsonWriter with given output stream.
-
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] )
-
def
fromJson[T](json: JsonValue)(implicit input: JsonInput[T]): T
Converts JsonValue to T value.
-
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()
-
def
obj(fields: (String, JsonValue)*): JsonObject
Creates JsonObject from list of fields.
-
def
parse(file: File): JsonStructure
Parses text from given file to JsonStructure.
-
def
parse(reader: Reader): JsonStructure
Parses text from given reader to JsonStructure.
-
def
parse(in: InputStream): JsonStructure
Parses text from given input stream to JsonStructure.
-
def
parse(text: String): JsonStructure
Parses given text to JsonStructure.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toJson[T](value: T)(implicit output: JsonOutput[T]): JsonValue
Converts T value to JsonValue.
-
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()