Class

net.liftweb.json.JsonAST

JDouble

Related Doc: package JsonAST

Permalink

case class JDouble(num: Double) extends JValue with Product with Serializable

Linear Supertypes
Serializable, Serializable, Product, Equals, JValue, Diffable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. JDouble
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. JValue
  7. Diffable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new JDouble(num: Double)

    Permalink

Type Members

  1. type Values = Double

    Permalink
    Definition Classes
    JDoubleJValue
  2. final class WithFilter extends AnyRef

    Permalink
    Definition Classes
    JValue

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++(other: JValue): JValue

    Permalink

    Concatenate this JValue with another JValue.

    Concatenate this JValue with another JValue.

    Example:

    > JArray(JInt(1) :: JInt(2) :: Nil) ++ JArray(JInt(3) :: Nil)
    res0: JArray(List(JInt(1), JInt(2), JInt(3)))
    Definition Classes
    JValue
  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def \[A <: JValue](clazz: Class[A]): List[JValue.\.A.Values]

    Permalink

    Find immediate children of this JValue that match a specific JValue subclass.

    Find immediate children of this JValue that match a specific JValue subclass.

    This methid will search a JObject or JArray for values of a specific type and return a List of those values if they any are found.

    So given some JSON like so:

    [
      {
        "thinga":1,
        "thingb":"bacon"
      },{
        "thingc":3,
        "thingd":"Wakka"
      },{
        "thinge":{
          "thingf":4
        },
        "thingg":true
      }
    ]

    You would use this method like so:

    scala> json \ classOf[JInt]
    res0: List[net.liftweb.json.JInt#Values] = List(1, 3)

    This method does require that whatever type you're searching for is subtype of JValue.

    Definition Classes
    JValue
  6. def \(nameToFind: String): JValue

    Permalink

    An XPath-like expression to find a child of a JObject or a JArray of JObject by name.

    An XPath-like expression to find a child of a JObject or a JArray of JObject by name. If you call this method on anything other than a JObject or JArray of JObjects you'll get a JNothing.

    This method is most useful if you have an object that you need to dig into in order to retrieve a specific value. So, let's say that you had a JSON object that looked something like this:

    {
      "name": "Joe",
      "profession": "Software Engineer",
      "catchphrase": {
        "name": "Alabama Cheer",
        "value": "Roll tide"
      }
    }

    If for some reason you're interested in taking a look at Joe's catchphrase, you can query it using the \ method to find it like so:

    Example:

    scala> json \ "catchphrase"
    res0: JValue = JObject(List(JField("name", JString("Alabama Cheer")), JField("value", JString("Roll tide"))))

    Likewise, if you wanted to find Joe's name you could do the following:

    scala> json \ "name"
    res0: JValue = JString("Joe")

    The result could be any subclass of JValue. In the event that the JValue you're operating on is actually an array of objects, you'll get back a JArray of the result of executing \ on each object in the array. In the event nothing is found, you'll get a JNothing.

    Definition Classes
    JValue
  7. def \\[A <: JValue](clazz: Class[A]): List[JValue.\\.A.Values]

    Permalink

    Find all descendants of this JValue that match a specific JValue subclass.

    Find all descendants of this JValue that match a specific JValue subclass.

    Unlike its cousin \, this method will recurse down into all children looking for type matches searching a JObject or JArray for values of a specific type and return a List of those values if they are found.

    So given some JSON like so:

    [
      {
        "thinga":1,
        "thingb":"bacon"
      },{
        "thingc":3,
        "thingd":"Wakka"
      },{
        "thinge":{
          "thingf":4
        },
        "thingg":true
      }
    ]

    You would use this method like so:

    scala> json \\ classOf[JInt]
    res0: List[net.liftweb.json.JInt#Values] = List(1, 3, 4)
    Definition Classes
    JValue
  8. def \\(nameToFind: String): JObject

    Permalink

    Find all children of a JObject with the matching name, returning an empty JObject if no matches are found.

    Find all children of a JObject with the matching name, returning an empty JObject if no matches are found.

    For example given this example JSON:

    {
      "name": "Joe",
      "profession": "Software Engineer",
      "catchphrase": {
        "name": "Alabama Cheer",
        "value": "Roll tide"
      }
    }

    We might do the following:

    scala> json \\ "name"
    res2: JValue = JObject(List(JField(name,JString(Joe)), JField(name,JString(Alabama Cheer))))
    Definition Classes
    JValue
  9. def apply(i: Int): JValue

    Permalink

    Return the element in the i-th position from a JArray.

    Return the element in the i-th position from a JArray. Will return JNothing when invoked on any other kind of JValue.

    For example:

    scala> val array = JArray(JInt(1) :: JInt(2) :: Nil)
    array: net.liftweb.json.JsonAST.JArray = JArray(List(JInt(1), JInt(2)))
    
    scala> array(1)
    res0: net.liftweb.json.JsonAST.JValue = JInt(2)
    Definition Classes
    JValue
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def children: List[JValue]

    Permalink

    Return direct child elements of this JValue, if this JValue is a JObject or JArray.

    Return direct child elements of this JValue, if this JValue is a JObject or JArray.

    This method is useful for getting all the values of a JObject or JArray and will return them as a List[JValue]. If the JValue you invoke this method on is not a JObject or JArray you will instead get Nil.

    Example:

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

    Direct children of this JValue if it is a JObject or JArray, or JNothing otherwise.

    Definition Classes
    JValue
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def diff(other: json.JValue): Diff

    Permalink

    Return a diff.

    Return a diff.

    Definition Classes
    Diffable
    See also

    net.liftweb.json.Diff#diff

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

    Permalink
    Definition Classes
    AnyRef
  15. def extract[A](implicit formats: Formats, mf: Manifest[A]): A

    Permalink

    Extract a value into a concrete Scala instance from its JValue representation.

    Extract a value into a concrete Scala instance from its JValue representation.

    Value can be:

    • a case class
    • a primitive (String, Boolean, Date, etc.)>
    • any type which has a configured custom deserializer
    • a supported collection type of any of the above (List, Seq, Map[String, _], Set)

    Example:

    > case class Person(name: String)
    > JObject(JField("name", JString("joe")) :: Nil).extract[Person]
    res0: Person("joe")
    Definition Classes
    JValue
  16. def extractOpt[A](implicit formats: Formats, mf: Manifest[A]): Option[A]

    Permalink

    Optionally extract a value into a concrete Scala instance from its JValue representation.

    Optionally extract a value into a concrete Scala instance from its JValue representation.

    This method will attempt to extract a concrete Scala instance of type A, but if it fails it will return a scala.None instead of throwing an exception as extract would.

    Value can be:

    • a case class
    • a primitive (String, Boolean, Date, etc.)>
    • any type which has a configured custom deserializer
    • a supported collection type of any of the above (List, Seq, Map[String, _], Set)

    Example:

    scala> case class Person(name: String)
    defined class Person
    
    scala> implicit val formats = DefaultFormats
    formats: net.liftweb.json.DefaultFormats.type = net.liftweb.json.DefaultFormats$@39afbb7c
    
    scala> JObject(JField("name", JString("joe")) :: Nil).extractOpt[Person]
    res1: Option[Person] = Some(Person(joe))
    Definition Classes
    JValue
  17. def extractOrElse[A](default: ⇒ A)(implicit formats: Formats, mf: Manifest[A]): A

    Permalink

    Attempt to extract a concrete Scala instance of type A from this JValue and, on failing to do so, return the default value instead.

    Attempt to extract a concrete Scala instance of type A from this JValue and, on failing to do so, return the default value instead.

    Value can be:

    • a case class
    • a primitive (String, Boolean, Date, etc.)>
    • any type which has a configured custom deserializer
    • a supported collection type of any of the above (List, Seq, Map[String, _], Set)

    Example:

    > case class Person(name: String)
    > JNothing.extractOrElse(Person("joe"))
    res0: Person("joe")
    Definition Classes
    JValue
  18. def filter(p: (JValue) ⇒ Boolean): List[JValue]

    Permalink

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

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

    Example:

    > JArray(JInt(1) :: JInt(2) :: Nil) filter {
      case JInt(x) => x > 1
      case _ => false
    }
    res0: List[net.liftweb.json.JsonAST.JValue] = List(JInt(2))

    This operates recursively, so nested objects work too:

    > ((("boom" -> ("slam" -> "hello")) ~ ("shap" -> 3)): JObject) filter {
      case JString("hello") => true
      case _ => false
    }
    res0: List[net.liftweb.json.JsonAST.JValue] = List(JString(hello))
    Definition Classes
    JValue
  19. def filterField(p: (JField) ⇒ Boolean): List[JField]

    Permalink

    Return a List of all fields that match the given predicate.

    Return a List of all fields that match the given predicate. Does not recurse into child elements, so this will only check a JObject's field values.

    Example:

    > JObject(JField("age", JInt(10))) filterField {
      case JField("age", JInt(x)) if x > 18 =>
        true
    
      case _ =>
        false
    }
    res0: List[net.liftweb.json.JsonAST.JField] = List()
    > JObject(JField("age", JInt(10))) filterField {
      case JField("age", JInt(x)) if x < 18 =>
        true
    
      case _ =>
        false
    }
    res1: List[net.liftweb.json.JsonAST.JField] = List(JField(age,JInt(10)))
    returns

    A List of JFields that match the given predicate p, or Nil if this JValue is not a JObject.

    Definition Classes
    JValue
  20. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def find(p: (JValue) ⇒ Boolean): Option[JValue]

    Permalink

    Return the first element from a JValue which matches the given predicate.

    Return the first element from a JValue which matches the given predicate.

    Example:

    > JArray(JInt(1) :: JInt(2) :: Nil) find { _ == JInt(2) }
    res0: Option[net.liftweb.json.JsonAST.JValue] = Some(JInt(2))
    Definition Classes
    JValue
  22. def findField(p: (JField) ⇒ Boolean): Option[JField]

    Permalink

    Return the first field from this JValue which matches the given predicate.

    Return the first field from this JValue which matches the given predicate.

    When invoked on a JObject it will first attempt to see if the JObject has the field defined on it. Not finding the field defined, this method will recurse into the fields of that object and search for the value there. When invoked on or encountering a JArray during recursion this method will run its search on each member of the JArray.

    Example:

    > JObject(JField("age", JInt(2))) findField {
      case JField(n, v) =>
        n == "age"
    }
    res0: Option[net.liftweb.json.JsonAST.JField] = Some(JField(age,JInt(2))
    Definition Classes
    JValue
  23. def fold[A](z: A)(f: (A, JValue) ⇒ A): A

    Permalink

    Fold over JValues by applying a function to each element.

    Fold over JValues by applying a function to each element.

    z

    The initial value for the fold.

    f

    The function to apply, which takes an accumulator and the next item as paramaters.

    Definition Classes
    JValue
  24. def foldField[A](z: A)(f: (A, JField) ⇒ A): A

    Permalink

    Fold over a series of JFields applying a function to each one.

    Fold over a series of JFields applying a function to each one.

    z

    The initial value for the fold.

    f

    The function to apply, which takes an accumulator as its first parameter and the next field as its second.

    Definition Classes
    JValue
  25. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    Any
  27. def map(f: (JValue) ⇒ JValue): JValue

    Permalink

    Return a new JValue resulting from applying the given function to each value, recursively.

    Return a new JValue resulting from applying the given function to each value, recursively.

    If this function is invoked on a JObject, it will iterate over the field values of that JObject. If this function is invoked on a JArray, it will iterate over the values of that JArray. If this function is invoked on any other kind of JValue it will simply pass that instance into the function you have provided.

    Example:

    JArray(JInt(1) :: JInt(2) :: Nil) map {
      case JInt(x) => JInt(x+1)
      case x => x
    }
    Definition Classes
    JValue
  28. def mapField(f: (JField) ⇒ JField): JValue

    Permalink

    Return a new JValue resulting from applying the given function to each JField in a JObject or a JArray of JObject, recursively.

    Return a new JValue resulting from applying the given function to each JField in a JObject or a JArray of JObject, recursively.

    Example:

    JObject(("age", JInt(10)) :: Nil) map {
      case ("age", JInt(x)) => ("age", JInt(x+1))
      case x => x
    }
    Definition Classes
    JValue
    See also

    transformField

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

    Permalink
    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. val num: Double

    Permalink
  33. def remove(p: (JValue) ⇒ Boolean): JValue

    Permalink

    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)
    res0: net.liftweb.json.JsonAST.JValue = JArray(List(JInt(1), JInt(2), JNothing))
    Definition Classes
    JValue
  34. def removeField(p: (JField) ⇒ Boolean): JValue

    Permalink

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

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

    Example:

    > JObject(JField("age", JInt(10))) removeField {
      case JField("age", _) => true
      case _          => false
    }
    Definition Classes
    JValue
  35. def replace(l: List[String], replacement: JValue): JValue

    Permalink

    Return a new JValue resulting from replacing the value at the specified field path with the replacement value provided.

    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 instance.

    Example:

    > JObject(List(JField("foo", JObject(List(JField("bar", JInt(1))))))).replace("foo" :: "bar" :: Nil, JString("baz"))
    JObject(List(JField("foo", JObject(List(JField("bar", JString("baz")))))))
    Definition Classes
    JValue
  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  37. def toOpt: Option[JValue]

    Permalink
    Definition Classes
    JValue
  38. def transform(f: PartialFunction[JValue, JValue]): JValue

    Permalink

    Return a new JValue resulting from applying the given partial function to each value within this JValue.

    Return a new JValue resulting from applying the given partial function to each value within this JValue.

    If this is a JArray, this means we will transform each value in the array and return an updated array.

    If this is a JObject, this means we will transform the value of each field of the object and the object in turn and return an updated object.

    If this is another type of JValue, the value is transformed directly.

    Note that this happens recursively, so you will receive both each value in an array and the array itself, or each field value in an object and the object itself. If an array contains arrays, we will recurse into them in turn.

    Examples:

    > JArray(JInt(1) :: JInt(2) :: Nil) transform {
      case JInt(x) =>
        JInt(x+1)
    }
    res0: net.liftweb.json.JsonAST.JValue = JArray(List(JInt(2), JInt(3)))

    Without type matching, notice that we get the result of the transform replacing the array:

    > JArray(JInt(1) :: JInt(2) :: Nil) transform {
      case _ =>
        JString("hello")
    }
    res0: net.liftweb.json.JsonAST.JValue = JString("hello")
    returns

    This JValue with its child values recursively transformed by the given PartialFunction, when defined. If the PartialFunction is undefined, leaves the child values untouched.

    Definition Classes
    JValue
  39. def transformField(f: PartialFunction[JField, JField]): JValue

    Permalink

    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))
    }
    Definition Classes
    JValue
  40. def values: Double

    Permalink

    Return a representation of the values in this JValue in a native Scala structure.

    Return a representation of the values in this JValue in a native Scala structure.

    For example, you might invoke this on a JObject to have its fields returned as a Map.

    scala> JObject(JField("name", JString("joe")) :: Nil).values
    res0: scala.collection.immutable.Map[String,Any] = Map(name -> joe)
    Definition Classes
    JDoubleJValue
  41. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. def withFilter(p: (JValue) ⇒ Boolean): WithFilter

    Permalink

    Create a new instance of WithFilter for Scala to use when using this JValue in a for comprehension.

    Create a new instance of WithFilter for Scala to use when using this JValue in a for comprehension.

    Definition Classes
    JValue

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from JValue

Inherited from Diffable

Inherited from AnyRef

Inherited from Any

Ungrouped