Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1
-
Fix Version/s: 1.3.3
-
Labels:None
-
Number of attachments :
Description
Repeated element names on different types cause incorrect construction of json strings.
Take the following xsd which defines a "Company" with a list of "phone" elements. The company contains a "Person" that also has a "phone" element.
<xs:element name="TestResult">
<xs:complexType>
<xs:sequence>
<xs:element name="company" type="Company" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Company">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="phone" type="Phone" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ceo" type="Person" minOccurs="0" maxOccurs="1" />
<xs:element name="address" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Person">
<xs:sequence>
<xs:element name="firstName" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="phone" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Phone">
<xs:sequence>
<xs:element name="type" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="number" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
If you construct the company to have one phone number, and the ceo has a phone number, when constructing JSON the phone number of the ceo (Person) is placed into the Company's phone list.
Take the following xml:
<TestResult> <company> <name>Acme Co.</name> <phone> <type>main</type> <number>1234567890</number> </phone> <ceo> <firstName>John</firstName> <phone>0987654321</phone> </ceo> <address>123 Main St</address> </company> </TestResult>
The JSON created for that structure is:
{
"TestResult":{
"company":{
"name":"Acme Co.",
"phone":[
{
"type":"main",
"number":1234567890
},
"0987654321"
],
"ceo":{
"firstName":"John"
}
}
},
"address":"123 Main St"
}
Note how the ceo's phone "0987654321" incorrectly becomes an element in the list of phones on the company