Previous Topic: Generic XML Payload Parser Data ProtocolNext Topic: Request Data Copier Data Protocol


JSON Data Protocol

The JSON data protocol is used to convert JSON data to an XML equivalent and to convert XML data to JSON format.

For example, the data protocol converts the following JSON data:

[
	{"organizationType":"W",
	 "parentOrganizationType":"S",
	 "parentUnitNbr":777,
	 "positionName":"S",
	 "positionType":"S",
	 "positionTypeId":56,
	 "unitNbr":433,
	 "l":
		[{"Roles":["P","P1","P2","S","C","AC","ACF","ACM"]}],
	 "groupKey":"P",
	 "groupName":"P"
	}
]

to the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<element class="object">
		<groupKey type="string">P</groupKey>
		<groupName type="string">P</groupName>
		<l class="array">
			<element class="object">
				<Roles class="array">
					<element type="string">P</element>
					<element type="string">P1</element>
					<element type="string">P2</element>
					<element type="string">S</element>
					<element type="string">C</element>
					<element type="string">AC</element>
					<element type="string">ACF</element>
					<element type="string">ACM</element>
				</Roles>
			</element>
		</l>
		<organizationType type="string">W</organizationType>
		<parentOrganizationType type="string">S</parentOrganizationType>
		<parentUnitNbr type="number">777</parentUnitNbr>
		<positionName type="string">S</positionName>
		<positionType type="string">S</positionType>
		<positionTypeId type="number">56</positionTypeId>
		<unitNbr type="number">433</unitNbr>
	</element>
</root>

If the JSON contains a one-element array, the data protocol converts it to an object with "element" as the key. For example, the data protocol converts the following JSON data:

[{"question1":"answer1","question2":"answer2"}]

into the following XML:

{"element":{"question1":"answer1","question2":"answer2"}}

The JSON data protocol handler reorders the key/value pairs in an object so they are alphabetical by key name.

Note: Recording JSON works properly if the application type is set correctly to application/json, text/json, or text/javascript. If the wrong application type is set, recording fails.