0

please let me know how we can convert below json request into multiple xml elements. Is it good to convert json into xml and then split xml based on Person tag and do processing or we can directly use json and convert it to output format input request:

 {
 "Persons":{
 "Person": [
  {
 "LineID": 123456,
"Attributes": { "PersonMap": "Emp1,Emp2" },
"Department": 10
},
{
 "LineID": 123456,
"Attributes": { "PersonMap": "Emp3,Emp4" },
"Department": 20
}
]
 }
  }

output expected:

<Records>
 <EmpRec>
  <id>Emp1</id>
  <dept>10</dept>    
 </EmpRec>
 <EmpRec>
 <id>Emp2</id>
 <dept>10</dept>    
 </EmpRec>
 <EmpRec>
<id>Emp3</id>
<dept>20</dept>    
</EmpRec>
<EmpRec>
<id>Emp4</id>
<dept>20</dept>
</EmpRec>
</Records>

Thanks in advance...

7
  • what language/platform are you using? Commented Nov 10, 2017 at 13:10
  • trying to achieve it using xslt as am using apache camel as integration Commented Nov 10, 2017 at 13:12
  • as far as I know, xslt takes xml as input but you have a json. Commented Nov 10, 2017 at 13:12
  • agree, so the only option is to convert json into xml and then do xml to xml transformation using xslt? Commented Nov 10, 2017 at 13:21
  • I think so. There are some libraries and tools for converting json to xml, and even if it's not the exact xml output you need, it can then be processed by an xslt. Commented Nov 10, 2017 at 13:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.