JPath -- search and validation utilities for JSON -- Method Reference

Validation Methods

isJSONArray

Returns true if the invoking object is a JSON Array (a sequence of comma-separated values).

isJSONObject

Returns true if the invoking object is a JSON Object (an unordered set of comma-separated name/value pairs).

isJSONString

Returns true if the invoking object is a JSON String (a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes).

isJSONNumber

Returns true if the invoking object is a JSON Number (a series of decimal digits in either standard or scientific notation).

isJSONBoolean

Returns true if the invoking object would be evaluated by JavaScript as true or false.

isJSONNull

Returns true if the invoking object is a JSON null value (any value that JavaScript considers null).

jsonType

Returns the JSON type of the invoking object (Object, String, Boolean, Number and its subclasses, or Null).

Utility and Meta Methods

abs(number)

Returns the absolute value for the given number i.e., abs(-3.14) = 3.14

any(closure)

Iterates over the properties of the invoking object, and returns true if the closure expression is true for at least one of the iterated values.

contains(property)

When invoked by a String or Collection type (a JSON object or array), returns true if and only if the collection or String contains the supplied property.

count(value)

Returns the number of occurences of the given value inside the invoking object. This works for all collection types, as well as Strings.

depthFirst(closure)

Recursively travels the object graph, starting from the invoking object, returning the first object for which the given closure evaluates to true.

depthFirstAll(closure)

Recursively travels the object graph, starting from the invoking object, returning a JSON Array of all objects for which the given closure evaluates to true.

each(closure)

Iterates over the properties of the invoking object, invoking the supplied closure on each item. N.B. This method does not return the value if the invocations, but rather a reference to the invoking object.

eachWithIndex(closure)

Iterates over the properties of the invoking object, invoking the supplied closure on each item. Additionally supplies each item's index (starting with zero) for use inside the closure. N.B. This method does not return the value if the invocations, but rather a reference to the invoking object.

equals(leftside, rightside)

Returns true if the leftside object and the rightside object are equivalent, i.e., if they contain the same data. This works for collection types, Strings, and Numbers.

every(closure)

Iterates over the properties of the invoking object, and returns true if the closure expression is true for all of the iterated values.

find(closure)

Iterates over the properties of the invoking object, returning the first property for which the closure expression is true.

findAll(closure)

Iterates over the properties of the invoking object, returning all properties for which the closure expression is true.

hasProperty(propertyName)

Returns true if the invoking object has a property of the supplied property name.

size

Returns the size of the invoking object. In the case of collection types, the size is the number of entries held by the collection. For Strings, it is the length of the String.