• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

xml to JSON conversion issue

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 352
21
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't appear to be a Clojure question - why is it posted here?
 
Marshal
Posts: 26132
77
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. I scanned through it but then decided not to post because I know nothing about Clojure and didn't want to make a fool of myself. Perhaps others felt the same way.

Perhaps the OP could report the post and ask for it to be moved into a more suitable forum?
 
Harish Maridi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to XML forum, posted here due to my overlook.

Thanks,
HM
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic