Categorygithub.com/project-flogo/contrib/function/json
modulepackage
0.11.0
Repository: https://github.com/project-flogo/contrib.git
Documentation: pkg.go.dev

# README

JSON Functions

This function package exposes common json functions.

exists()

Check if the key/JSONPath is present in the json object. Refer https://github.com/oliveagle/jsonpath for expression format.

Input Args

ArgTypeDescription
objectanyThe json object
keystringThe key or JSONPath to check

Output

ArgTypeDescription
returnValboolTrue if value is associated with the key / JSONPath

get()

Get value of associated key from json object

Input Args

ArgTypeDescription
objectanyThe json object
keystringThe key for which the value to get

Output

ArgTypeDescription
returnValanyThe value associated with the key

length()

Get the number of top level elements in json object or array

Input Args

ArgTypeDescription
jsonObjectOrArrayanyThe json object or array

Output

ArgTypeDescription
lengthIntegerintThe top level items in the json object

numbersToString()

Convert every number type to string in a json object or array

Input Args

ArgTypeDescription
jsonObjectOrArrayanyThe json object or array

Output

ArgTypeDescription
jsonObjectOrArrayanyThe json object or array with numbers encoded as strings

objKeys()

Get the list of all top level keys of json object

Input Args

ArgTypeDescription
objectanyThe json object

Output

ArgTypeDescription
arrayOfStringsarrayThe list of top level keys

objValues()

Get the list of all top level values of json object

Input Args

ArgTypeDescription
objectanyThe json object

Output

ArgTypeDescription
arrayOfValuesarrayThe list of all top level values in json object

path()

Apply a JSON path to an object.

Input Args

ArgTypeDescription
pathstringThe JSON path
objectanyThe object to apply the JSON path to

Output

ArgTypeDescription
returnValanyThe result of the JSON path

set()

Set the value of existing key or add new key and set it's value in a json object

Input Args

ArgTypeDescription
objectanyThe json object
keystringThe key for value
valueanyThe value for key

Output

ArgTypeDescription
jsonObjectanyThe updated json object

jq()

Process the JSON inputs based on a provided query and return the filtered output

Input Args

ArgTypeDescription
objectanyThe json object
querystringQuery to perform

Output

ArgTypeDescription
outputanyresult of the jq filter