How to parse unordered JSON String and validating the output XML string against XSD using Parse JSON Activity?
book
Article ID: KB0076728
calendar_today
Updated On:
Products
Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON
ALL
Description
Sometimes users want to parse an unordered JSON String along with validation of generated output XML string using Parse JSON Activity.
Resolution
To parse unordered JSON String using Parse JSON Activity and also to validate the generated XML String(Using Schema type as XSD and Validate Output option in configuration tab. Refer attached image ParseJsonConfig.jpg), use all element(<xs:all>) instead of sequence element(<xs:sequence>) in XSD schema where we are expecting the elements will be in unordered manner. For example, to parse the unordered JSON strings given below: 1)Ordered JSON String: ***************************** { "sample1":"Hi", "sample2":"Hello" } ***************************** 2)Unordered JSON String: ***************************** { "sample2":"Hello", "sample1":"Hi" } *****************************
use below element in XSD: ***************************** <xs:element name="sampleUnorderedJsonParse"> <xs:complexType> <xs:all> <xs:element name="sample1" type="xs:string" /> <xs:element name="sample2" type="xs:string" /> </xs:all> </xs:complexType> </xs:element> *****************************
Please refer attached sample project.
Issue/Introduction
Parsing and validating unordered JSON String using XSD.
Additional Information
case id: 01800793,01677926
Attachments
How to parse unordered JSON String and validating the output XML string against XSD using Parse JSON Activity?get_app
How to parse unordered JSON String and validating the output XML string against XSD using Parse JSON Activity?get_app