cancel
Showing results for 
Search instead for 
Did you mean: 

JSON to XML

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Hi all,

anybody knows if exists of has an generic XSLT to transform XML to Json protocol to integrate with mobile devices?

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

A little bit Off Topic... please, excuse me... I have a personal project/idea to create a Custom Adapter Module for JSON integration with PI.

Somebody can be interested to contribute?

It can be usefull regarding Mobile Application integration with Sap XI/PI, rather than develope Custom Handler in Abap.

Former Member
0 Kudos

Hi Rodrigo,

The link that you have posted, can be really helpful!

Former Member
0 Kudos

Hi Rodrigo,

This link doesn't show any thing..

Regards

former_member181962
Active Contributor
0 Kudos

If you are open to other types of mapping, you can follow this wiki for XML to JSON transformation using ABAP:

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=163840922

Best Regards,

Ravi

baskar_gopalakrishnan2
Active Contributor
0 Kudos

This is possible. If you are looking for XSLT logic to convert xml to json ... Please google there are plenty of good websites.

I believe you are looking for mapping logic to convert xml to json using XSLT mapping.

Here is one good site

http://www.bizcoder.com/index.php/2010/02/12/convert-xml-to-json-using-xslt/

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Baskar,

the XLST work perfect, but how should i implement it in PI?? i cant see the way

Thanks

baskar_gopalakrishnan2
Active Contributor
0 Kudos

> but how should i implement it in PI?? i cant see the way

Implement XSLT mapping..

Save your XSL file as zip file. In PI create new imported archive and import the zip file. In operation mapping select source and target interfaces and at the mapping program section select type XSL file and look for your XSLT zip file.

Refer this [link |http://www.riyaz.net/blog/xslt-mapping-a-simple-example/technology/sap/808/]also

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

baskal,

sorry i did not explain propely.

i know how to import a XLS mapping in pi. but the result in this case is not a XML document,so its not clear to me what to define in the operation mapping as target Operation.

is not clear tome how to configure the ID if there is no target service.

do you have any sugguest??

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I thought you will wrap everything as a single string and pass it to target system. Also talk to target system and their support in terms of functionality like HTTP or webservice or so....?

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

sorry, its not clear to me.

i need to wrap it in a single string inside a xml field and later, in the http receiver channel convert the xml to plain?

that is it??

if not could you explain me a little more?

Rgds

RP

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>i need to wrap it in a single string inside a xml field

Yes.

It is fully based on your target side requirement. What I'm saying is send the entire json output as a string element to target system. If the target side supports HTTP then post it to that system using http receiver and let them decide about processing your json output string. Hope you understand.

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi,

i followed you. my doubt is about how to configure PI to send the data to target system.

as i commented you before when configuring the OM, the system request me to define a source operation, target operation and a mapping program

i should send the Json as it is and avoid to send it in a XML file,¿ or is there any standar module that i can implement in the receiver HTTP adapter to transform the XML to plain?

Source Operation: Si_ClientMobileRequest

Mapping: XML2Json.xls

Target Operation: ?????

how should i configure the OM in ESR and how to configure the ID??

is it possible??

Thanks

RP

Edited by: Rodrigo Alejandro Pertierra on Jul 5, 2011 3:18 PM

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>my doubt is about how to configure PI to send the data to target system.

You need to talk to target system and see what type of service they support. If they have web based appllication then you can use HTTP adapter in the receiver side.

>how should i configure the OM in ESR and how to configure the ID??

DIscuss with target system... Create XML structure and have a field of type string and fill your entire json output as string value.

example:

<target>

<output> json output here </output>

</target>

Post this data via http adapter to target system. If they support web service , use their web service. Once you created target structure use source and targe in the OM and pick xsl file as mapping.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

as i commented you before when configuring the OM, the system request me to define a source operation, target operation and a mapping program

Yes, once you create an operation mapping, the operations become mandatory. Actually, it does not matter what you declare in your target operation. Even if you declare a simple type data type -> message type -> target interface, the output of the operation mapping depends on the output of the last mapping program that you have declared in it. As such, the output of the last mapping takes PRECEDENCE in an operation mapping.

take the case of adding a prolog manually via java mapping (for SOAP over HTTP scenarios):

Source XML


<SourceXML>
 <Data/>
</SourceXML>

Target XML


<TargetXML />

Java Mapping will convert the source xml into string and add &elements= to the output

So the declaration in the operation mapping would be

SI_OUT_Source (Source XML message type) -> Java Mapping -> SI_IN_Target (Target XML Type)

The output would be


&elements=<SourceXML><Data/></SourceXML>

The output would not be viewable via tree view, only by source view. As you can see, it does not match the declared target XML. Same with your case, this should be okay.

Hope this helps,

Mark

Edited by: Mark Dihiansan on Jul 6, 2011 3:59 AM

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi Mark

so no matter which target SI y define in the OM the result of the last mapping takes precedence and this result is sent to target system?? I was traying to test it but the system was down and still it is.

if this case "doest work" would i be able to use the estandar module xml2plain in a receiver HTTP adapter --> the solution that Baskar suggeuest.

Thanks

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

so no matter which target SI y define in the OM the result of the last mapping takes precedence and this result is sent to target system??

Yup, this is correct.

if this case "doest work" would i be able to use the estandar module xml2plain in a receiver HTTP adapter --> the solution that Baskar suggeuest.

It is not possible to use modules in the Plain HTTP Adapter because it resides on the ABAP stack. To use modules, you can opt for SOAP Adapter with Do Not Use SOAP Enveloped checked. I can't say if the xml2plain would work. Let's wait for other replies.

Hope this helps,

Mark

Former Member
0 Kudos

Hello Bhaskar,

Request you to share XSLT transformation to JSON or any other code, if you have, to achieve JSON from XML.

Thanks in anticipation.

With Regards,

Garima

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>Request you to share XSLT transformation to JSON or any other code, if you have, to achieve JSON from XML. Please refer the link provided in my reply. This has some sample code for converting xml to json using XSLT

Former Member
0 Kudos

Thanks for your reply!

I tried the link already but is not showing up anything. That is the reason had to request you

Thanks,

Garima