This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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: 24933
61
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
 
I was born with webbed fish toes. This tiny ad is my only friend:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!