cancel
Showing results for 
Search instead for 
Did you mean: 

sap pi rest convert xml to json

mark_fryu
Participant
0 Kudos

I have a stream of soap to rest

I have an xml like:

<field1> test </field1>

<field2> test2 </field1>

and I convert it to json, during the conversion I need the "records" field to be inserted as an array at the beginning, like this:

{"records": [{"field1": "test", "field2": "test2",}]}

the records field is an array, in fact after the ":" there is a [

pls help me

Accepted Solutions (1)

Accepted Solutions (1)

Nandu143
Explorer
0 Kudos

Go to receiver REST channel > Data Format tab > Maintain below entry in Custom XML/JSON Conversion rule table

Namespace is your namespace coming in xml payload

mark_fryu
Participant
0 Kudos

thanks i managed!

the last question, how do I manage multiplicity?

for example I have to pass:

{"records": [{"field1": "test", "field2": "test2"}, {"field1": "test", "field2": "test2"}]}

you can notice that between }, { ends one and the other begins

thank you so much

Answers (1)

Answers (1)

MetinD
Participant
0 Kudos

Hi,

you should insert "records" field and no need namespace in conversion rule just name and array type

mark_fryu
Participant
0 Kudos

thanks i managed!

the last question, how do I manage multiplicity?

for example I have to pass:

{"records": [{"field1": "test", "field2": "test2"}, {"field1": "test", "field2": "test2"}]}

you can notice that between }, { ends one and the other begins

thank you so much