RESTful JSON service using XQuery.
Configuration steps to follow :
Configuration steps to follow :
- Configure a match action by selecting the matching URL as "*".
- Drag the Transform Action and select the option "Transform with a processing control file, if specified".
- Then upload a file with an extension .xq : jsoniq.xq to convert JSON to XML.
- Choose the options as shown below:
Input Language : JSON
- Drag the advanced action and configure the skip-backside.
Here are the sample XQueries for different transformations :
To convert JSON into a text format , then upload the following XQuery :
File : Json2Text_JSONiq.xq
declare option jsoniq-version "0.4.42";
("Order by: ", .("name"), "
",
"Price: ", .("price"), "
" ,
"Ship to: ", .("shipTo")("state"))
To Perform the JSON extraction , then upload the following XQuery :
File : JSONiq_Extract.xq
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option jsoniq-version "0.4.42";
declare option output:method "json";
.("shipTo")
File : jsoniq.xq
<root>
<name>{.{"name"}}</name>
<street>{.{"street"}}</street>
<city>{.{"city"}}</city>
<state>{.{"state}}</state>
<zip>{.{"zip"}</zip>
</person>
</root>
