JSON functions
This page describes the additional set of predefined Jsonnet functions for the Data Transformer Script task available in Application Integration.
Before you begin
To use the following predefined functions, you must import the functions
library in your script. Importing the functions
library lets you use both the standard Jsonnet functions and the predefined Data Transformer functions.
Application Integration supports Jsonnet functions library v0.20.0. For information about the Jsonnet standard functions, see Jsonnet Standard Library.
Manifest XML
Syntax |
manifestXml(json, format = "badgerfish", indent_output = false) |
---|---|
Description | Converts the specified input JSON object into a XML string. |
Input parameter | json: The input JSON object.
format: The input JSON representation format. indent_output: Boolean input to indicate if the output XML string should be indented. Default value is |
Return type | STRING
|
Output | Returns the XML string of the provided JSON object representation. |
Object Remove Key
Syntax |
objectRemoveKey(obj, key) |
---|---|
Description | Removes a property from a JSON object. |
Input parameter | obj: The input JSON object.
key: The JSON property to remove. |
Return type | JSON
|
Output | Updated JSON object after removing the specified property and its corresponding value. |
Parse XML
Syntax |
parseXml(xml, format = "badgerfish") |
---|---|
Description | Parses the specified input XML string into a JSON object. |
Input parameter | xml: The input XML string.
format: The output JSON representation format. |
Return type | JSON
|
Output | Returns the JSON object representation of the provided XML string. |
Parse CSV With Header
Syntax |
parseCsvWithHeader(input, delimiter = ",", overwrite_duplicate_headers = true) |
---|---|
Description | Parse given input csv string as json. The first row would be considered as header. For example, f.parseCsvWithHeader("index,product,company\n1,Application Integration,Google\n2,Pubsub,Google") would generate [{"index": "1", "product": "Application Integration", "company": "Google"},{"index": "2", "product": "Pubsub", "company": "Google"}] .
|
Input parameter | input: The CSV string to be parsed.
delimiter: Delimiter string to be used. Default value is ','. overwrite_duplicate_headers: Option to overwrite values for the duplicate headers. If set to false, duplicate header would be renamed. Default value is |
Return type | JSON
|
Output | Returns the json representation of given csv string. |
Manifest CSV
Syntax |
manifestCsv(json, headers = null) |
---|---|
Description | Convert given json into csv string. For example, f.manifestCsv([{"index": "1", "product": "Application Integration", "company": "Google"},{"index": "2", "product": "Pubsub", "company": "Google"}]) would generate index,product,company\n1,Application Integration,Google\n2,Pubsub,Google .
|
Input parameter | json: JSON to be converted into csv.
headers: Headers list for csv output. If no value is provided, it would use all the headers. |
Return type | STRING
|
Output | Returns the csv string from json in given format. |
Resolve JSON Path
Syntax |
resolveJsonPath(obj, path) |
---|---|
Description | Resolves a JSON path on a given JSON object by using the JSONPath reference.
|
Input parameter | obj: The input JSON object.
path: The JSON path string. |
Return type | JSON
|
Output | Returns the JSON object or value at the provided path. |
Recommendation
- Learn how to add and configure a Data Transformer Script task (Preview)