DynamicJValue

org.json4s.DynamicJValue
See theDynamicJValue companion object
class DynamicJValue(val raw: JValue) extends Dynamic

Attributes

Companion
object
Source
DynamicJValue.scala
Graph
Supertypes
trait Dynamic
class Object
trait Matchable
class Any

Members list

Type members

Types

type Values
Implicitly added by dynamic2Jv

Attributes

Source
JValue.scala

Value members

Abstract methods

def values: Values
Implicitly added by dynamic2Jv

Return unboxed values from JSON

Return unboxed values from JSON

Example:

JObject(JField("name", JString("joe")) :: Nil).values == Map("name" -> "joe")

Attributes

Source
JValue.scala

Concrete methods

def ++(other: JValue): JValue
Implicitly added by dynamic2Jv

Concatenate with another JSON. This is a concatenation monoid: (JValue, ++, JNothing)

Concatenate with another JSON. This is a concatenation monoid: (JValue, ++, JNothing)

Example:

JArray(JInt(1) :: JInt(2) :: Nil) ++ JArray(JInt(3) :: Nil) ==
JArray(List(JInt(1), JInt(2), JInt(3)))

Attributes

Source
JValue.scala
def \(nameToFind: String): JValue
Implicitly added by dynamic2monadic

XPath-like expression to query JSON fields by name. Matches only fields on next level.

XPath-like expression to query JSON fields by name. Matches only fields on next level.

Example:

json \ "name"

Attributes

Source
MonadicJValue.scala
def \[A <: JValue](clazz: Class[A]): List[ValuesType[A]]
Implicitly added by dynamic2monadic

XPath-like expression to query JSON fields by type. Matches only fields on next level.

XPath-like expression to query JSON fields by type. Matches only fields on next level.

Example:

json \ classOf[JInt]

Attributes

Source
MonadicJValue.scala
def \\(nameToFind: String): JValue
Implicitly added by dynamic2monadic

XPath-like expression to query JSON fields by name. Returns all matching fields.

XPath-like expression to query JSON fields by name. Returns all matching fields.

Example:

json \\ "name"

Attributes

Source
MonadicJValue.scala
def \\[A <: JValue](clazz: Class[A]): List[ValuesType[A]]
Implicitly added by dynamic2monadic

XPath-like expression to query JSON fields by type. Returns all matching fields.

XPath-like expression to query JSON fields by type. Returns all matching fields.

Example:

json \\ classOf[JInt]

Attributes

Source
MonadicJValue.scala
def apply(i: Int): JValue
Implicitly added by dynamic2Jv

Return nth element from JSON. Meaningful only to JArray, JObject and JField. Returns JNothing for other types.

Return nth element from JSON. Meaningful only to JArray, JObject and JField. Returns JNothing for other types.

Example:

JArray(JInt(1) :: JInt(2) :: Nil)(1) == JInt(2)

Attributes

Source
JValue.scala
Implicitly added by dynamic2monadic

Camelize all the keys in this org.json4s.JValue

Camelize all the keys in this org.json4s.JValue

Attributes

Source
MonadicJValue.scala
def children: List[JValue]
Implicitly added by dynamic2Jv

Return direct child elements.

Return direct child elements.

Example:

JArray(JInt(1) :: JInt(2) :: Nil).children == List(JInt(1), JInt(2))

Attributes

Source
JValue.scala
override def equals(p1: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
Source
DynamicJValue.scala
def filter(p: JValue => Boolean): List[JValue]
Implicitly added by dynamic2monadic

Return a List of all values which matches the given predicate.

Return a List of all values which matches the given predicate.

Example:

JArray(JInt(1) :: JInt(2) :: Nil) filter { case JInt(x) => x > 1; case _ => false }

Attributes

Source
MonadicJValue.scala
def filterField(p: JField => Boolean): List[JField]
Implicitly added by dynamic2monadic

Return a List of all fields which matches the given predicate.

Return a List of all fields which matches the given predicate.

Example:

JObject(("age", JInt(10)) :: Nil) filterField {
 case ("age", JInt(x)) if x > 18 => true
 case _          => false
}

Attributes

Source
MonadicJValue.scala
def find(p: JValue => Boolean): Option[JValue]
Implicitly added by dynamic2monadic

Return the first element from JSON which matches the given predicate.

Return the first element from JSON which matches the given predicate.

Example:

JArray(JInt(1) :: JInt(2) :: Nil) find { _ == JInt(2) } == Some(JInt(2))

Attributes

Source
MonadicJValue.scala
def findField(p: JField => Boolean): Option[JField]
Implicitly added by dynamic2monadic

Return the first field from JSON which matches the given predicate.

Return the first field from JSON which matches the given predicate.

Example:

JObject(("age", JInt(2))) findField { case (n, v) => n == "age" }

Attributes

Source
MonadicJValue.scala
def fold[A](z: A)(f: (A, JValue) => A): A
Implicitly added by dynamic2monadic

Return a combined value by folding over JSON by applying a function f for each element. The initial value is z.

Return a combined value by folding over JSON by applying a function f for each element. The initial value is z.

Attributes

Source
MonadicJValue.scala
def foldField[A](z: A)(f: (A, JField) => A): A
Implicitly added by dynamic2monadic

Return a combined value by folding over JSON by applying a function f for each field. The initial value is z.

Return a combined value by folding over JSON by applying a function f for each field. The initial value is z.

Attributes

Source
MonadicJValue.scala
override def hashCode(): Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
Source
DynamicJValue.scala
def map(f: JValue => JValue): JValue
Implicitly added by dynamic2monadic

Return a new JValue resulting from applying the given function f to each value in JSON.

Return a new JValue resulting from applying the given function f to each value in JSON.

Example:

JArray(JInt(1) :: JInt(2) :: Nil) map {
 case JInt(x) => JInt(x+1)
 case x => x
}

Attributes

Source
MonadicJValue.scala
Implicitly added by dynamic2monadic

Return a new JValue resulting from applying the given function f to each field in JSON.

Return a new JValue resulting from applying the given function f to each field in JSON.

Example:

JObject(("age", JInt(10)) :: Nil) mapField {
 case ("age", JInt(x)) => ("age", JInt(x+1))
 case x => x
}

Attributes

Source
MonadicJValue.scala
Implicitly added by dynamic2monadic

Remove the org.json4s.JNothing and org.json4s.JNull from a org.json4s.JArray or org.json4s.JObject

Remove the org.json4s.JNothing and org.json4s.JNull from a org.json4s.JArray or org.json4s.JObject

Attributes

Source
MonadicJValue.scala
Implicitly added by dynamic2monadic

Pascalize all the keys in this org.json4s.JValue

Pascalize all the keys in this org.json4s.JValue

Attributes

Source
MonadicJValue.scala
def remove(p: JValue => Boolean): JValue
Implicitly added by dynamic2monadic

Return a JSON where all values matching the given predicate are removed.

Return a JSON where all values matching the given predicate are removed.

Example:

JArray(JInt(1) :: JInt(2) :: JNull :: Nil) remove { _ == JNull }

Attributes

Source
MonadicJValue.scala
def removeField(p: JField => Boolean): JValue
Implicitly added by dynamic2monadic

Return a JSON where all fields matching the given predicate are removed.

Return a JSON where all fields matching the given predicate are removed.

Example:

JObject(("age", JInt(10)) :: Nil) removeField {
 case ("age", _) => true
 case _          => false
}

Attributes

Source
MonadicJValue.scala
def replace(l: List[String], replacement: JValue): JValue
Implicitly added by dynamic2monadic

Return a new JValue resulting from replacing the value at the specified field path with the replacement value provided. This has no effect if the path is empty or if the value is not a JObject or JArray instance. If the path is a JArray you must use the following annotation "foo[]", each element, or foo[index], one element.

Return a new JValue resulting from replacing the value at the specified field path with the replacement value provided. This has no effect if the path is empty or if the value is not a JObject or JArray instance. If the path is a JArray you must use the following annotation "foo[]", each element, or foo[index], one element.

Example:

JObject(List(JField("foo", JObject(List(JField("bar", JInt(1))))))).replace("foo" :: "bar" :: Nil, JString("baz"))
// returns JObject(List(JField("foo", JObject(List(JField("bar", JString("baz")))))))
JObject(List(JField("foo", JArray(List(JObject(List(JField("bar", JInt(1)))), JObject(List(JField("bar", JInt(2))))))))).replace("foo[]" :: "bar" :: Nil, JString("baz"))
// returns JObject(List((foo,JArray(List(JObject(List((bar,JString(baz)))), JObject(List((bar,JString(baz)))))))))
JObject(List(JField("foo", JArray(List(JObject(List(JField("bar", JInt(1)))), JObject(List(JField("bar", JInt(2))))))))).replace("foo[0]" :: "bar" :: Nil, JString("baz"))
// returns JObject(List((foo,JArray(List(JObject(List((bar,JString(baz)))), JObject(List((bar,JInt(2)))))))))

Attributes

Source
MonadicJValue.scala
def selectDynamic(name: String): DynamicJValue

Adds dynamic style to JValues. Only meaningful for JObjects

Adds dynamic style to JValues. Only meaningful for JObjects

Example:

JObject(JField("name",JString("joe"))::Nil).name == JString("joe")

Attributes

Source
DynamicJValue.scala
Implicitly added by dynamic2monadic

Underscore all the keys in this org.json4s.JValue

Underscore all the keys in this org.json4s.JValue

Attributes

Source
MonadicJValue.scala
def toOption: Option[JValue]
Implicitly added by dynamic2Jv

When this org.json4s.JValue is a org.json4s.JNothing or a org.json4s.JNull, this method returns scala.None When it has a value it will return scala.Some

When this org.json4s.JValue is a org.json4s.JNothing or a org.json4s.JNull, this method returns scala.None When it has a value it will return scala.Some

Attributes

Source
JValue.scala
def toSome: Option[JValue]
Implicitly added by dynamic2Jv

When this org.json4s.JValue is a org.json4s.JNothing, this method returns scala.None When it has a value it will return scala.Some

When this org.json4s.JValue is a org.json4s.JNothing, this method returns scala.None When it has a value it will return scala.Some

Attributes

Source
JValue.scala
def transform(f: PartialFunction[JValue, JValue]): JValue
Implicitly added by dynamic2monadic

Return a new JValue resulting from applying the given partial function f to each value in JSON.

Return a new JValue resulting from applying the given partial function f to each value in JSON.

Example:

JArray(JInt(1) :: JInt(2) :: Nil) transform { case JInt(x) => JInt(x+1) }

Attributes

Source
MonadicJValue.scala
def transformField(f: PartialFunction[JField, JField]): JValue
Implicitly added by dynamic2monadic

Return a new JValue resulting from applying the given partial function f to each field in JSON.

Return a new JValue resulting from applying the given partial function f to each field in JSON.

Example:

JObject(("age", JInt(10)) :: Nil) transformField {
 case ("age", JInt(x)) => ("age", JInt(x+1))
}

Attributes

Source
MonadicJValue.scala
Implicitly added by dynamic2monadic

Underscore the camel cased only keys in this org.json4s.JValue

Underscore the camel cased only keys in this org.json4s.JValue

Attributes

Source
MonadicJValue.scala
Implicitly added by dynamic2monadic

Underscore all the keys in this org.json4s.JValue

Underscore all the keys in this org.json4s.JValue

Attributes

Source
MonadicJValue.scala
def withFilter(p: JValue => Boolean): JValueWithFilter
Implicitly added by dynamic2monadic

Attributes

Source
MonadicJValue.scala

Inherited methods

def canEqual(that: Any): Boolean
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Equals
def diff(other: JValue): Diff
Implicitly added by dynamic2Jv

Return a diff.

Return a diff.

Attributes

See also

org.json4s.Diff#diff

Inherited from:
Diffable (hidden)
Source
Diff.scala
def productArity: Int
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product
def productElement(n: Int): Any
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product
def productElementName(n: Int): String
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product
def productElementNames: Iterator[String]
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product
def productPrefix: String
Implicitly added by dynamic2Jv

Attributes

Inherited from:
Product

Concrete fields

val raw: JValue

Attributes

Source
DynamicJValue.scala