When a message flow is configured to use the JSON domain,
the JSON parser automatically detects JSONP messages. The JSON parser
puts the JSON padding in the top level Padding
element,
and the JSON data under the Data
element.
Before you begin
Before completing this task, read the following overview
topics about JSON:
About this task
You can process both JSON and JSONP messages in a single
message flow, because the parser puts the JSON data under the Data
element
in the message tree. If JSONP padding is detected, the name of the
client-side script is placed in the top level Padding
element.Follow
these steps to test for the presence of padding:
Procedure
- Create a message flow with an HTTPInput
node, an HTTPReply node,
and your choice of a Computeor JavaCompute node.
- On the Input Message Parsing tab
of your HTTPInput node,
set the Message domain property
to JSON : For JavaScript Object
Notation messages.
- Insert the following code, as appropriate:
- If your message flow uses a Compute node:
DECLARE PaddingRef REFERENCE TO InputRoot.JSON.Padding
IF LASTMOVE(PaddingRef) THEN
-- JSON Padding is present
ELSE
-- No JSON Padding present
END IF;
- If your message flow uses a JavaCompute node:
if (message.getRootElement().getFirstElementByPath("JSON/Padding") != null){
//JSON Padding is present
}
else{
//No JSON Padding
}