Appendix : Legacy Presto components : Mashables and Mashups : Mashups in EMML : Advanced Mashup Techniques : Handling JSON Responses or Inputs : Accept JSON as Input and Modify with <script>
Accept JSON as Input and Modify with <script>
If you need to manipulate a JSON variable in a mashup or macro without converting the data to XML, you must use JavaScript in the <script> statement. You can also accept a JSON object as an input parameter, such as this example macro:
...
<macro name="getFirstJsonCity" >
<output name="cityStats" type="document" subtype="JSON"/>
<input name="jsonCities" type="document" subtype="JSON"/>

<script type="text/javascript" inputvariables="jsonCities"
outputvariable="cityStats">
<![CDATA[
var jsonObj = JSON.parse(jsonCities);
cityStats = JSON.stringify(jsonObj.locations[1]);

]]>
</script>
</macro>
...
This example is a macro, but you can use these same techniques in a mashup also.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback