com.persist

JsonOps

object JsonOps

Provides types and functions for working with Json types.

Json is represented by immutable Scala types. Instead of having separate Json types, type aliases are defined for Json forms.

Scala types used for Json are

- Json Object. Immutable Map[String,Json]. Note that keys are not ordered. When converting to a string with Compact or Pretty keys are sorted. - Json Array. Immutable Seq[Json] - Json String. String - Json Boolean. Boolean - Json Number. Int, Long, BigDecimal (with .), Double (with e) - Json Null. Null

Any of the Json types can be at the top level of a document (not just array and object).

The Json parser supports some extensions that are useful for human edited Json input (such as configurations).

- Comments. The characters // to end of line are discarded during parsing. - Scala-like raw strings. Start with ""{ and end with }"". Treated as normal strings after parsing. - No quotes on simple names. If an object component name starts with a letter and contains only letters and digits the " quotes are not required. After parsing names with and without quotes are not distinguished.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. JsonOps
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type Json = Any

    A type alias for all Json forms.

    A type alias for all Json forms. Json values should be restricted by convention to only those types used to represent Json.

  2. type JsonArray = Seq[Json]

    A type alias for Json Arrays.

  3. type JsonObject = Map[String, Json]

    A type alias for of Json Objects.

  4. case class jfield(ilist: Any*) extends Product with Serializable

    An extractor for nested Json values.

    An extractor for nested Json values.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    Example:
    1. val A = jfield("a")
      val B = jfield("b")
      val C = jfield("c")
      jval match {
        case a:A & b:B => foo(a,b)
        case c:C => bar(c)
      }

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. object &

    An extractor composition operator.

    An extractor composition operator.

    Example:
    1. val A = jfield("a")
      val B = jfield("b")
      val C = jfield("c")
      jval match {
        case a:A & b:B => foo(a,b)
        case c:C => bar(c)
      }
  4. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  5. def Compact(j: Json, safe: Boolean = false): String

    A Json unparser.

    A Json unparser. It produces the most compact single line string form.

  6. def Json(s: String): Json

    A Json parser.

  7. def JsonArray(elements: Json*): JsonArray

    A constructor for JsonArray.

    A constructor for JsonArray.

    elements

    a sequence of array element values.

    returns

    the constructed Json Array.

  8. def JsonObject(pairs: (String, Json)*): JsonObject

    A constructor for JsonObject.

    A constructor for JsonObject.

    pairs

    a sequence of name value pairs.

    returns

    the constructed Json Object.

  9. def Pretty(j: Json, indent: Int = 0, width: Int = 50, count: Int = 6, safe: Boolean = false): String

    A Json unparser.

    A Json unparser. It produces a multiple line form designed for human readability.

  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. val emptyJsonArray: Seq[Any]

    An empty JsonArray.

  13. val emptyJsonObject: Map[String, Any]

    An empty JsonObject.

  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  19. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  20. def jdelete(a: Json, ilist: Any*): Json

    Delete a value within a nested Json value.

    Delete a value within a nested Json value.

    a

    the input Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    a copy of the input with the value replaced.

  21. def jget(a: Json, ilist: Any*): Json

    Get a value within a nested Json value.

    Get a value within a nested Json value.

    a

    the input Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected value or null if not present.

  22. def jgetArray(a: Json, ilist: Any*): JsonArray

    Get a JsonArray value within a nested Json value.

    Get a JsonArray value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected JsonArray value or an empty JsonArray if not present.

  23. def jgetBigDecimal(a: Json, ilist: Any*): BigDecimal

    Get a big decimal value within a nested Json value.

    Get a big decimal value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected big decimal value or 0.0 if not present.

  24. def jgetBoolean(a: Json, ilist: Any*): Boolean

    Get a boolean value within a nested Json value.

    Get a boolean value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected boolean value or false if not present.

  25. def jgetDouble(a: Json, ilist: Any*): Double

    Get a double value within a nested Json value.

    Get a double value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected double value or 0.0 if not present.

  26. def jgetInt(a: Json, ilist: Any*): Int

    Get an integer value within a nested Json value.

    Get an integer value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected integer value or 0 if not present.

  27. def jgetLong(a: Json, ilist: Any*): Long

    Get a long value within a nested Json value.

    Get a long value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected long value or 0 if not present.

  28. def jgetObject(a: Json, ilist: Any*): JsonObject

    Get a JsonObject value within a nested Json value.

    Get a JsonObject value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected JsonObject value or an empty JsonObject if not present.

  29. def jgetString(a: Json, ilist: Any*): String

    Get a string value within a nested Json value.

    Get a string value within a nested Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    the selected string value or "" if not present.

  30. def jhas(a: Json, ilist: Any*): Boolean

    Tests if a nested Json value is present.

    Tests if a nested Json value is present.

    a

    the input Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    returns

    true if the selected field is present.

  31. def jinsert(a: Json, ilist: Any*)(v: Json): Json

    Insert a value within a nested Json value.

    Insert a value within a nested Json value.

    a

    the input Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    v

    the new value

    returns

    a copy of the input with the value inserted. For JsonArrays the value is inserted before the specified value.

  32. val jnull: Json

    The Json null value.

  33. def jput(a: Json, ilist: Any*)(v: Json): Json

    Replace a value within a nested Json value.

    Replace a value within a nested Json value.

    a

    the input Json value.

    ilist

    a list of values that are either strings or integers

    • A string selects the value of a JsonObject name-value pair where the name equals the string.
    • An integer i selects the ith elements of a JsonArray.
    v

    the new value.

    returns

    a copy of the input with the value replaced.

  34. def jsize(j: Json): Int

    Get the size of a Json value.

    Get the size of a Json value. - For a Json Object the number of name-value pairs. - For a Json Array the number of elements. - For anything else, 0.

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. final def notify(): Unit

    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  39. def toString(): String

    Definition Classes
    AnyRef → Any
  40. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped