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 = "FORMAT", indent_output = false)
|
|---|---|
| Description | Converts the specified input JSON object into an XML string. |
| Input parameter | json: The input JSON object.
format: The input JSON representation format. Replace FORMAT with one of the following supported formats:
manifestXml(jsonObject, "badgerfish", false)
[or]
manifestXml(jsonArray, "jsonml", false)
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. |
JSON to String
| Syntax |
jsonToString(input)
|
|---|---|
| Description | Converts the specified JSON object or array into a JSON string. For example, f.jsonToString({"name": "Jane"}) returns "{\"name\":\"Jane\"}".
|
| Input parameter | input: The input JSON object or array to convert into a string. |
| Return type | STRING
|
| Output | Returns the string representation of the input JSON value. |
Parse XML JsonML
| Syntax |
parseXmlJsonml(input, preserveWhitespace = false)
|
|---|---|
| Description | Parses the specified input XML string into a JSON array in JsonML format. For example, f.parseXmlJsonml("<svg><circle>FooBar</circle></svg>") returns ["svg", ["circle", "FooBar"]].
|
| Input parameter | input: The input XML string to parse.
preserveWhitespace: A boolean value that indicates whether to preserve leading and trailing whitespace in XML character data. The default value is |
| Return type | ARRAY
|
| Output | Returns the JsonML array representation of the input XML string. |
Recommendation
- Learn how to add and configure a Data Transformer Script task (Preview)