# JsonPath reference

This is the complete reference for JSONPath projection functions.## Introduction

This page contains the definition and reference for all JSONPath projection functions. To read more on how to use JSONPath projection see the section about using JSONPath projections.

### Function argument defaults

To provide a simpler API that is easier to use, function arguments have default values provided for them when no value is provided in the projection definition. The default values are:

Field | Supported type(s) |
---|---|

`eventSelector` | `$.event` |

`targetSelector` | `$.projection` |

`eventFilter` | No value provided |

`targetFilter` | No value provided |

`rawData` | No value provided |

## Basic object modification

The following sections contains functions that can be used for basic object modification.

### merge

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Object` |

`targetFilter` | `Filter expression` |

`targetSelector` Required | `Object` |

`rawData` | `Object` |

### Merge complete event data

`{ "eventType": "OrderStatusChangedEvent", "functions": [ { "function": "merge" } ] }`

### set

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Any` |

`targetFilter` | `Filter expression` |

`targetSelector` Required | `Any` |

`rawData` | `Any` |

### Update a single field from a field in the event

`{ "eventType": "OrderPlaced", "functions": [ { "function": "set", "eventSelector": "$.event.status", "targetSelector": "$.projection.status" } ] }`

### unset

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Filter expression` |

`targetSelector` Required | `Any` |

`rawData` | `Unsupported` |

### Remove a single field from the projection

`{ "eventType": "CreditCardNumberCleared", "functions": [ { "function": "unset", "targetSelector": "$.projection.customer.creditCardNumber" } ] }`

### clear

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Filter expression` |

`targetSelector` Required | `Any` |

`rawData` | `Unsupported` |

#### Default data types

When the field is cleared, the data in the projection will be reset to a default value. Depending on what data type the object in the projection has, the default value will be different. The following table shows the default values for different data types:

Data type | Supported type(s) |
---|---|

`String` | `""` |

`Boolean` | `false` |

`Number` | `0` |

`Array` | `[]` |

`Object` | `{}` |

### Clear all items in a list

`{ "eventType": "ShoppingBagCleared", "functions": [ { "function": "clear", "targetSelector": "$.projection.items" } ] }`

### delete

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Unsupported` |

`targetSelector` | `Unsupported` |

`rawData` | `Unsupported` |

### Delete a projection

`{ "eventType": "OrderDeleted", "functions": [ { "function": "delete" } ] }`

## Collection functions

The following functions can be used to work with collections such as **Arrays**/**Lists** and **Sets**.

### append

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Any` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Collection` |

`rawData` | `Any` |

### Append an item to a list

`{ "eventType": "OrderPlaced", "functions": [ { "function": "append", "targetSelector": "$.projection.placedOrders" } ] }`

### prepend

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Any` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Collection` |

`rawData` | `Any` |

### Prepend an item to a list

`{ "eventType": "OrderPlaced", "functions": [ { "function": "prepend", "targetSelector": "$.projection.placedOrders" } ] }`

### addtoset

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Any` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Collection` |

`rawData` | `Any` |

### Adds an element to a set

`{ "eventType": "UserLoggedIn", "functions": [ { "function": "addtoset", "eventSelector": "$.event['userId']", "targetSelector": "$.projection.activeUsers" } ] }`

## Arithmetic functions

The following functions can be used to perform simple arithmetic operations on numbers.

### add

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Number` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Number` |

`rawData` | `Number` |

### Add to a field

`{ "eventType": "OrderPlaced", "functions": [ { "function": "add", "eventSelector": "$.event['orderAmount']", "targetSelector": "$.projection.totalAmount" } ] }`

### inc

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Number` |

`rawData` | `Unsupported` |

### Increase a number by one

`{ "eventType": "OrderPlaced", "functions": [ { "function": "inc", "targetSelector": "$.projection.placedOrders" } ] }`

### subtract

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Number` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Number` |

`rawData` | `Number` |

### Subtract from a field

`{ "eventType": "OrderRefunded", "functions": [ { "function": "subtract", "eventSelector": "$.event['orderAmount']", "targetSelector": "$.projection.totalAmount" } ] }`

### dec

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Filter expression` |

`targetSelector` | `Number` |

`rawData` | `Unsupported` |

### Decrease a number by one

`{ "eventType": "OrderCanceled", "functions": [ { "function": "dec", "targetSelector": "$.projection.pendingOrders" } ] }`

## References

The following functions can be used to work with projection references.

### setref

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Unsupported` |

`targetSelector` | `String` /`Number` /`Date` |

`rawData` | `String` /`Number` /`Date` |

### Set a reference to a date field

`{ "eventType": "OrderPlaced", "functions": [ { "function": "set", "eventSelector": "$.event.orderDate" "targetSelector": "$.projection.orderDate" }, { "function": "setref", "targetSelector": "$.projection.orderDate" } ] }`

### clearref

#### Supported configuration

Field | Supported type(s) |
---|---|

`eventFilter` | `Filter expression` |

`eventSelector` | `Unsupported` |

`targetFilter` | `Unsupported` |

`targetSelector` | `Unsupported` |

`rawData` | `Unsupported` |

### Clear a reference

`{ "eventType": "OrderCanceled", "functions": [ { "function": "clearref" } ] }`