package json
Provides support for parsing and stringifying JSON.
This module is a new implementation; it does not depend on packages such as Jackson. This choice was to provide the following features:
- fewer dependencies, to make it easier to embed Histogrammar
- concise pattern-matching in org.dianahep.histogrammar.Container
fromJsonFragment
methods - special handling of
"-inf"
,"inf"
,"nan"
as numbers, rather than strings - partial parsing failures return
None
, rather than raising exceptions.
- Alphabetic
- By Inheritance
- json
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit class HasKeySet extends AnyRef
- class InvalidJsonException extends Exception
Exception type for strings that cannot be parsed because they are not proper JSON.
- sealed trait Json extends AnyRef
Interface for all parsed, in-memory JSON objects.
- case class JsonArray(elements: Json*) extends JsonContainer with Product with Serializable
Concrete class for JSON arrays.
Concrete class for JSON arrays.
- elements
Note: a varargs sequence; to fill from a Scala
Seq
, use themyseq: _*
syntax.
- trait JsonBoolean extends JsonPrimitive
Interface for JSON booleans (
true
andfalse
). - trait JsonContainer extends Json
Interface for all JSON containers: arrays and objects (mappings).
- case class JsonFloat(value: Double) extends JsonNumber with Product with Serializable
Concrete class for JSON floating point numbers.
Concrete class for JSON floating point numbers.
(
Double
type for more generality thanFloat
, though the JSON spec allows arbitrary precision). - class JsonFormatException extends Exception
Exception type for unexpected JSON structure, thrown by
fromJson
methods. - case class JsonInt(value: Long) extends JsonNumber with Product with Serializable
Concrete class for JSON integers.
Concrete class for JSON integers.
(
Long
type for more generality thanInt
, though the JSON spec allows arbitrary precision). - trait JsonNumber extends JsonPrimitive
Interface for JSON numbers, both integral and floating point.
- case class JsonObject(pairs: (JsonString, Json)*) extends JsonContainer with Product with Serializable
Concrete class for JSON objects (mappings).
Concrete class for JSON objects (mappings).
- pairs
Note: a varargs sequence; to fill from a Scala
Seq
, use themyseq: _*
syntax.
- trait JsonPrimitive extends Json
Interface for all JSON primitives:
null
,true
,false
, numbers, and strings. - case class JsonString(value: String) extends JsonPrimitive with Product with Serializable
Concrete class for JSON strings.
Concrete class for JSON strings.
Note: the strings
"-inf"
,"inf"
, and"nan"
can be interpreted as numbers by org.dianahep.histogrammar.json.JsonNumber. IfJsonNumber
parsing is attempted beforeJsonString
in anorElse
chain, these three values would become numbers; otherwise they would become strings. Standard parsing (provided by the org.dianahep.histogrammar.json.JsonPrimitive and org.dianahep.histogrammar.json.Json objects) attempts to interpret them as numbers first. - case class ParseState(str: String, pos: Int = 0) extends Product with Serializable
Status of JSON-parsing an in-memory string.
Status of JSON-parsing an in-memory string. Holds the position (
pos
), allows peeking (remaining
), and manages a stack of unwind-protection.
Value Members
- implicit def booleanToJson(x: Boolean): JsonBoolean with Product with Serializable
- implicit def byteToJson(x: Byte): JsonInt
- implicit def charToJson(x: Char): JsonString
- implicit def doubleToJson(x: Double): JsonFloat
- implicit def floatToJson(x: Float): JsonFloat
- implicit def intToJson(x: Int): JsonInt
- implicit def longToJson(x: Long): JsonInt
- implicit def shortToJson(x: Short): JsonInt
- implicit def stringToJson(x: String): JsonString
- object Json
Entry point for parsing JSON.
- object JsonArray extends Serializable
- object JsonBoolean
- object JsonContainer
- case object JsonFalse extends JsonBoolean with Product with Serializable
Concrete singleton for JSON
false
. - object JsonFloat extends Serializable
- object JsonInt extends Serializable
- case object JsonNull extends JsonPrimitive with Product with Serializable
Concrete singleton for JSON
null
. - object JsonNumber
- object JsonObject extends Serializable
- object JsonPrimitive
- object JsonString extends Serializable
- case object JsonTrue extends JsonBoolean with Product with Serializable
Concrete singleton for JSON
true
.