# JPath

JSONPath is a query language for JSON, often shortened to "JPath". Aggregations.io uses a simplified variation of JPath for filtering events and addressing individual properties.


# Addressing properties using JPath Notation

A JPath expression specifies a path to an element, or a set of elements, in a JSON structure. Paths can be specified with three notation types:

@.device.platform
@['device']['plaftorm']
@['device'].platform

# JPath Filters

# Operators

Operator Description Example
== Equal to. String values must be enclosed in single quotes (not double quotes) @.app.version == 2.0
!= Not equal to. String values must be enclosed in single quotes @.app.version != 2.0
> Greater than @.duration > 60
>= Greater than or equal to @.app.buildNum >= 4102
/< Less than @.app.buildNum < 3000
<= Less than or equal to @.app.version <= 1.9
LIKE String similarity comparison using % as wildcard. @.eventName LIKE 'app%'
ILIKE Case-Insensitive String similarity comparison, using % as wildcard. @.eventName ILIKE 'ApP%'
=~ Matches an re2 regular expression, surrounded by / to denote start & end. @.color =~ /gr(a|e)y/ Matches events where the color property is "grey" or "gray"
in Checks if the value is equal to one of provided values @.eventName in ['appOpen', 'appClose'] see array rules below.
Checks existence of a field @.error Matches events who have an error field
! Used to negate a filter !(@.color)
Matches items that do not have the color property.
&& Logical AND - used to combine multiple filter expressions @.app.version==2.0 && @.device.platform == 'ios'
|| Logical OR, used to combine multiple filter expressions @.eventName == 'AppClose' || @.eventNamne == 'AppBackground'
.length Used with array properties to compare array length @.player.weapons.length > 0

# Values

Value type Description
String String literals, ensure they are enclosed in single-quotes.
Numeric Number literals, 0 or 0.1 or -12345678910112 etc... When a numeric literal is the value, an attempt will be made to cast the field to a number (float), if that cast fails, the event is disregarded.
Boolean true or false. When a boolean literal is the value, the field specified will be cast to a boolean. If that cast fails, the event is disregarded.
Null null literals can be checked to confirm that a field exists and the value is explicitly null. If the field doesnt exist, it will not be included.
Array Array literals can be used with the in operator. Arrays of mixed types (strings, numbers) will all be considered strings. For example @.value in ['abc', 123] will be treated like @.value in ['abc','123'].
Regex Regex literals will be treated like regex, experimental. Uses Google's re2 syntax.

# Complex Payloads

Complex payloads are those that have spaces and other special characters in JSON property keys. To ensure proper JPath syntax, use bracket notation and/or \ as an escape character.

For spaces (and several other special characters), simply using bracket notation will work.

Certain special characters will require \ as an escape character, such as single quotes ('), double quotes (") and back-slash ().