Managing JSON-Formatted Documents

This section discusses how to:

  • Define a root label for a JSON document.

  • Define tag names for JSON document elements.

  • Omit the JSON label in generated JSON.

Define Root Labels for JSON Documents

When you create a JSON document, by default the system uses the root element label from the logical document as the JSON root label. You can use the default root label or define a different root label for the JSON document.

Use the Document Builder – JSON page to define a root element label for a JSON document. To access the page, select PeopleTools > Documents > Document Builder and click the JSON tab.

Image: Document Builder – JSON page

This example illustrates the Document Builder – JSON page. Use the JSON Details section to define a JSON root label.

Document Builder - JSON page

To define a root label for a JSON document:

  1. Access the Document Builder – JSON page (PeopleTools > Documents > Document Builder and click the JSON tab).

  2. In the JSON Details section, click the arrow icon to expand the section.

  3. In the JSON Label field enter a label for the JSON document.

  4. Click the Save button.

Note that if the JSON Label field is left blank, the system will default the field value to the root label of the logical document when you save the document.

Defining Tag Names for JSON Document Elements

By default for any element, the element name defined in the logical document is used as the JSON tag name for the element. However, you are able to define any JSON tag name you wish for an element.

Use the Document Builder – JSON page to define JSON tag names. To access the page, select PeopleTools > Documents > Document Builder and click the JSON tab.

When you access the Document Builder – JSON page and select an element in the document tree, on the right side of the page the name of the element as defined in the logical document appears in a read-only Element Name field for your reference. A JSON Tag Name field appears on the right side of the page as well. The field is populated with the default name of the element from the logical document. You can define a different value for the field for use when JSON data is generated or parsed.

In the previous example, the name element in the BillTo document is highlighted in the document tree. On the right side of the page the default element name, name, appears in the read-only Element Name field. The JSON Tag Name field shows that a value IB_NAME has been defined as the JSON tag name for the name element.

To define tag names for JSON document elements:

  1. Access the Document Builder – JSON page (PeopleTools > Documents > Document Builder and click the JSON tab).

  2. Click an element in the document tree.

    The Element Name field and the JSON Tag Name field appear on the right side of the page.

  3. In the JSON Tag Name field, enter a name.

  4. Click the Save button.

Omitting the JSON Label in Generated JSON

Use the Hide Parent Object Label box in the JSON Details section of the Document Builder – JSON page to omit the JSON label (object name of the parent document) in the generated JSON output.

Doing so provides more flexibility in creating third–party JSON strings.

The Hide Parent Object Label box is enabled only when a document is created using the Integration Broker Consume Web Service wizard.

Note: If the check box is not selected the JSON string to parse must have the parent JSON label present in the string and in the correct format.

The following examples show generated JSON for a document when the Hide Parent Object Label option is not used and when it is used.

Image: PeopleSoft Document

The examples in this section are based on the following PeopleSoft document.

PeopleSoft Document

This example illustrates the generated JSON when the Hide Parent Object Label is not used:

{"Contacts": {
"Contact_name": "Robby Naish","Contact_Title": "Flight Test Director","Contact_Phone": "x4354",
"ContactGround":
[
{"Contact_name": "Rob Tock","Contact_Title": "Ground Supervisor","Contact_phone": "x6577"},{
"Contact_name": "David Bourn","Contact_Title": "Ground Support","Contact_phone": "x6577"}
],"ContactsSupport": [
{"Contact_name": "Scott McDermott","Contact_Title": "Flight Support","Contact_phone": "x6533"}
]}
}

This example illustrates the generated JSON when the Hide Parent Object Label is used:

{
"Contact_name": "Robby Naish","Contact_Title": "Flight Test Director","Contact_Phone": "x4354",
"ContactGround":
[
{"Contact_name": "Rob Tock","Contact_Title": "Ground Supervisor","Contact_phone": "x6577"},{
"Contact_name": "David Bourn","Contact_Title": "Ground Support","Contact_phone": "x6577"}
],"ContactsSupport": [
{"Contact_name": "Scott McDermott","Contact_Title": "Flight Support","Contact_phone": "x6533"}
]}