JSON to application/x-www-form-urlencoded Service (com.ibi.agents.XDJsonToUrlEncodedAgent)

Syntax:

com.ibi.agents.XDJsonToUrlEncodedAgent

Description:

This service converts an input JSON document to application/x-www-form-urlencoded format. For example, this can prepare the document for a separate HTTP emit service to send a POST request to a RESTful API.

The input document must contain a parsed JSON Object. If the document is flat, it will be parsed as JSON first. If the JSON value is not a JSON object, or if the document contained parsed XML, the fail_format edge is returned with an error document. If the flat document cannot be parsed as JSON, the fail_parse edge is returned with an error document.

Every field of the JSON object declares a parameter in the output as show below:
name1=value1&name2=value2&…&nameN=valueN

Where nameN is the name of the Nth field in the JSON object, and valueN is the value of that field. The field names and the values are URL-encoded with UTF-8 encoding. The value of a Text field is the string without the quotation marks. The value null becomes the 4-character string null. Every other value is converted to string using toString(). It is valid for the JSON object to have no fields. The empty string is an acceptable value.

Parameters:

This service does not have parameters.

Edges:

The following table describes the edges that are returned by the JSON to application/x-www-form-urlencoded Service.

Edge

Description

success

Message was successfully sent.

fail_parse

A flat document cannot be parsed as JSON.

fail_format

Input document contains parsed XML, or the parsed JSON value is not a JSON Object.

Examples

The following table shows various input documents and the corresponding output document.

Input

Output

{}

<empty string>

{"f":"abc"}

f=abc

{"f":1}

f=1

{"f":1.2}

f=1.2

{"f":true}

f=true

{"f":null}

f=null

{"a name":"a value"}

a+name=a+value

{"f1":1,"f2":2}

f1=1&f2=2

{"f":{"f1":1,"f2":2}}

f=%7B%22f1%22%3A1%2C%22f2%22%3A2%7D

{"f":[1,"a"]}

f=%5B1%2C%22a%22%5D

true

fail_format with error document

}a{

fail_parse with error document