cancel
Showing results for 
Search instead for 
Did you mean: 

XML to JSON conversion for integer in CPI

mayankibm
Explorer
0 Kudos

Hi,

I am trying to convert XML field to JSON integer value through standard XML to convertor.

For example,Source is like:

<root><record><LineNo>1</LineNo><text>abcd</text></record></root>

Current output is:

{

"root": {

"record": {

"LineNo": "1",

"text": "abcd"

}

}

}

Expected output is:

{

"root": {

"record": {

"LineNo": 1,

"text": "abcd"

}

}

}

I understand as of now in standard there is no such option, but can same be done via groovy or XSLT mapping.

Also there can be multiple record segments in XML

Thanks in advance!

Mayank

Bais
Participant
0 Kudos

I've used a workaround:

On XML value I've added ::APOS:: wrapper key.

<LineNo>::APOS::1::APOS::</LineNo>

After XML to JSON conversion.

On groovy :

def xml = message.getBody(String)
xml.replaceAll('"::APOS::",'').replaceAll('::APOS::"', '') message.setBody(xml)
return message

Federico

Accepted Solutions (0)

Answers (0)