Hi,
I have following xml that I am looking to convert it to JSON, I am using XML.java class to convert, method toJSONObject(xml), Posted code below. braces are missing from different places.
Please let me know if my xml format is bad or is there anything I am missing.
Output that I am getting:
"orgInfo":"genesisId":,"regionName":"SALES ADMIN REGION","areaName":"SALES ADMIN","branchNumber":"088","branchName":"AV/ELECTRO AIR","areaId":"96","partyId":"1646171","jobRole":,"regionId":"96","jobRoleAcronym":},"managerInfo":"contactInfo":"eMail":,"name":"middle":,"last":,"salutation":,"first":},
"addressList":"address":"streetAddress3":,"streetAddress2":,"streetAddress1":,"zip":,"state":,"city":,"country":},"addressType":"Business"},"fax":},"employeeId":"38075"},
"contactInfo":"eMail":"harish.maridi@av.com","name":"last":"Maridi","first":"Harish"},"addressList":"address":"streetAddress3":,"streetAddress2":,"streetAddress1":,"zip":,
"state":,"city":,"country":},"addressType":"Business"},"phoneList":"phoneType":"Work","number":,"extension":}},"employeeId":"10031"}
Desired output::
{"orgInfo":{"genesisId":{},"regionName":"SALES ADMIN REGION","areaName":"SALES ADMIN","branchNumber":"088","branchName":"AV/ELECTRO AIR","areaId":"96",
"partyId":"1646171","jobRole":{},"jobRoleAcronym":{},"regionId":"96"},"managerInfo":{"contactInfo":{"eMail":{},"name":{"middle":{},"last":{},"salutation":{},"first":{}},
"addressList":{"address":{"streetAddress3":{},"streetAddress2":{},"streetAddress1":{},"zip":{},"state":{},"country":{},"city":{}},"addressType":"Business"},"fax":{}},
"employeeId":"38075"},"contactInfo":{"eMail":"harish.maridi@av.com","name":{"last":"Maridi","first":"Harish"},"addressList":{"address":{"streetAddress3":{},"streetAddress2":{},
"streetAddress1":{},"zip":{},"state":{},"country":{},"city":{}},"addressType":"Business"},"phoneList":{"phoneType":"Work","number":{},"extension":{}}},"profile":"authenticated","employeeId":"10031"}
Source XML::
<?xml version="1.0" encoding="UTF-8"?>
<ns3:queryEmployee xmlns:ns3="http://www.av.com/qryemp">
<queryEmployeeRequest>
<employeeId>10031</employeeId>
<getCustomerListFlag>false</getCustomerListFlag>
<getSupplierListFlag>false</getSupplierListFlag>
<msgCorrelationId>001</msgCorrelationId>
<getManagerInfoFlag>false</getManagerInfoFlag>
<getReporteesFlag>false</getReporteesFlag>
</queryEmployeeRequest>
<queryEmployeeResponse>
<employeeId>10031</employeeId>
<managerInfo>
<employeeId>38075</employeeId>
<contactInfo>
<eMail/>
<fax/>
<name>
<salutation/>
<first/>
<last/>
<middle/>
</name>
<addressList>
<addressType>Business</addressType>
<address>
<country/>
<zip/>
<state/>
<city/>
<streetAddress3/>
<streetAddress2/>
<streetAddress1/>
</address>
</addressList>
</contactInfo>
</managerInfo>
<contactInfo>
<eMail>
harish.maridi@av.com</eMail>
<name>
<first>Harish</first>
<last>Maridi</last>
</name>
<addressList>
<addressType>Business</addressType>
<address>
<country/>
<zip/>
<state/>
<city/>
<streetAddress3/>
<streetAddress2/>
<streetAddress1/>
</address>
</addressList>
<phoneList>
<phoneType>Work</phoneType>
<number/>
<extension/>
</phoneList>
</contactInfo>
<orgInfo>
<jobRole/>
<jobRoleAcronym/>
<genesisId/>
<partyId>1646171</partyId>
<regionId>96</regionId>
<regionName>SALES ADMIN REGION</regionName>
<areaId>96</areaId>
<areaName>SALES ADMIN</areaName>
<branchNumber>H88</branchNumber>
<branchName>AV/ELECTRO AIR</branchName>
</orgInfo>
</queryEmployeeResponse>
</ns3:queryEmployee>
Code of XML.java