Handling JSON Responses or Inputs
Some web services return complex results in the JavaScript Object Notation (JSON) format. Some may also expect complex input parameters in the JSON format. There are two possible solutions to work with JSON data in mashups or macros:
Pass or receive JSON data as strings and convert the JSON string to an XML document. Once converted to XML, you can use any
EMML statements to work with the data.
The conversion from JSON to XML can fail, however, due to discrepancies between the valid syntax of each. Some common problem areas include valid names in JSON that are not valid names in XML and arrays, which JSON supports but XML does not.
Work with JSON data as an object with limitations to what
EMML statements work with the data.
Input parameters, variables or the output parameter for a mashup or macro can have a datatype of document and a subtype of JSON, such as:
<input name="jsonInput" type="document" subtype="json"/>
<variable name="jsonVar" type="document" subtype="json"/>
<output name="jsonResult" type="document" subtype="json"/>
Parameters or variables with a JSON subtype, can be used directly only in these two EMML statements:
<script>: as an input variable or the output of the script, with JavaScript as the scripting language.