JSON Insertion Service (com.ibi.agents.XDJsonInsertAgent)

Syntax:

com.ibi.agents.XDJsonInsertAgent

Description:

The JSON Insertion Service inserts a value in a JSON document. The service requires a JSON input document, since any other type of document will return a fail_operation edge.

The data source can be left unparsed to be inserted as a string, or it can be parsed as a JSON literal allowing the insertion of typed values (for example, a JSON object, JSON array, a quoted string, a number, a Boolean, or null).

The value is inserted in one or more parents selected by a JsonPath expression. Selecting no parents causes the fail_notfound edge to be returned. Selecting more than one parent causes the value to be duplicated. A parent can be a JSON object or an array.

The key determines where the value is inserted within the parent. If the parent is an object, then the key is the name of the field. If the field already exists, then the value replaces the old value. Otherwise, a new field is created. If the parent is an array, then the key is the index within the array and the value replaces the old value at that index. If the index is larger than the array length, then the array is first extended with null values. If the key is left blank, then the value is appended after the last element.

Parameters:

Parameter

Description

Data Source

The string or JSON data to insert in the document.

Data Format

Determines how the Data Source is interpreted. The String format treats the Data Source as character data. The JSON format parses the Data Source as a JSON value.

Parent Path

A JsonPath expression returning one or more parents where to assign the JSON value. A parent can be a JSON object or a JSON array.

Key

Determines where to store the value in the parent. For a JSON object parent, this is the key in the map. For a JSON array parent, this is the index in the array, where an empty string means append to the end, which causes the array to grow by 1.

Edges:

The following table lists and describes the edges that are returned by the JSON Insertion Service.

Edge

Description

success

The value was successfully inserted.

fail_parse

An iFL, JSON, or a JsonPath expression could not be evaluated.

fail_notfound

No parents were selected.

fail_operation

The operation could not be completed successfully.

Examples: