Object

razie.xp

JsonSolver

Related Doc: package xp

Permalink

object JsonSolver extends XpSolver[JsonWrapper]

NOTE that JSON xpath must start with "/root/..."

resolving JSON structures

NOTE to use JSON you need the json library, add this SBT/maven dependency:

val json = "org.json" % "json" % "20090211"

In Eclipse, pick up this library from lib_managed/

Linear Supertypes
XpSolver[JsonWrapper], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JsonSolver
  2. XpSolver
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type CONT = List[JsonWrapper]

    Permalink
  2. type T = JsonWrapper

    Permalink
  3. type U = List[JsonWrapper]

    Permalink

    type U stands for the continuation that following methods pass to themselves.

    type U stands for the continuation that following methods pass to themselves.

    Ideally it's just a closure that can implement getNext(curr: (T, U), tag: String, assoc: String): Iterable[(T, U)]

    So options include

    type U = List[MyWrapper] and type U = PartialFunction[(String, String), List[MyWrapper]] // basically getNext (tag, assoc)

    The continuation is very good when getting the kids is expensive, like a DB query, eh?

    Definition Classes
    JsonSolverXpSolver

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def WrapA(j: JSONArray, label: String = "root"): JsonAWrapper

    Permalink
  5. def WrapO(j: JSONObject, label: String = "root"): JsonOWrapper

    Permalink
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def children(root: T, xe: Option[XpElement]): (T, U)

    Permalink

    prepare to start from a node, figure out the continuations.

    prepare to start from a node, figure out the continuations.

    This is only used to start, from the root - then getNext is used

    You can return an actual list of nodes or a callback that you then call from getNext to get the actuals

    root

    the node we'll start resolving from

    xe

    - optional the current path element - you can use cond to filter result set directly when querying

    Definition Classes
    JsonSolverXpSolver
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def getAttr(o: T, attr: String): String

    Permalink

    get the value of an attribute from the given node

    get the value of an attribute from the given node

    returns

    the value, toString, of the attribute

    Definition Classes
    JsonSolverXpSolver
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def getNext(o: (T, U), tag: String, assoc: String, xe: Option[XpElement]): List[(T, U)]

    Permalink

    browsing json is different since only the parent konws the name of the child...

    browsing json is different since only the parent konws the name of the child... a JSON Object doesn't know its own name/label/tag

    xe

    - optional the current path element - you can use cond to filter result set directly when querying

    Definition Classes
    JsonSolverXpSolver
  15. def hashCode(): Int

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

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  20. def reduce(curr: Iterable[(T, U)], xe: XpElement): Iterable[(T, U)]

    Permalink

    reduce the current set of possible nodes based on the given condition.

    reduce the current set of possible nodes based on the given condition. Note that the condition may be null - this is still called to give you a chance to cleanup?

    This default implementation may be ok for most resolvers

    NOTE - if you choose to filter in getNext, then you don't have to filter here...

    curr

    the list of (currelement, continuation) to reduce

    Definition Classes
    JsonSolverXpSolver
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  22. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  23. def unwrap(root: List[JsonWrapper]): List[JsonWrapper]

    Permalink

    finally unwrap whatever and serve plain objects

    finally unwrap whatever and serve plain objects

    root

    the node we'll start resolving from

    Definition Classes
    XpSolver
  24. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def wrapOorA(body: String, label: String = "root"): JsonWrapper

    Permalink

Inherited from XpSolver[JsonWrapper]

Inherited from AnyRef

Inherited from Any

Ungrouped