<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: REST JSON Response in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427439#M4247034</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vadim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You mentioned &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;You may also develop and deploy your own type converter class (which should implement an interface org.codehaus.jettison.mapped.TypeConverter, method convertToJSONPrimitive()) and make use of it by Jettison if you need some advanced logic when producing elements values in JSON output.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;So I would need to write this class but how do I deploy this class ? Or do I go with an adapter module approach ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;I see we can use Moxy for this use case. &lt;A href="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html" title="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html"&gt;Java XML and JSON Binding: MOXy as Your JAX-RS JSON Provider - MOXyJsonProvider&lt;/A&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Not sure how to implement this.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Can I just use Jackson for the response in the java mapping and instruct the sender rest adapter not to do any xml to json conversion ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Thanks &lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Dec 2015 21:33:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2015-12-04T21:33:32Z</dc:date>
    <item>
      <title>REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaq-p/11427432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a sender REST scenario, where my sender is sending the JSON request to SAP PO, I am able to take the request map it to my receiver. When I am getting the response I need to convert the payload from XML to JSON. In this conversion I see an element which I have defined as String in xml in SAP PO that gets converted to integer in JSON response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"orderNo":"",&lt;/P&gt;&lt;P&gt;"taxTransactionDocID":"",&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"responseCode":500,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;"responseMessage":"Please select the address from proposed addressess "&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here in my xml I have defined responseCode as String but the value it carries is a number. When the response goes as JSON it shows up as a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="responseCode" type="xsd:string" minOccurs="0"/&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Dec 2015 02:29:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaq-p/11427432</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-12-03T02:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427433#M4247028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN style="color: #333333; font-size: 12px;"&gt;Ravijeet,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REST adapter uses 3rd party Jettison processor for JSON handling. Behaviour that you described, is a default way how Jettison processes XML and converts it into JSON. To be more precise, Jettison uses so-called type converter in order to make conversion of processed value when producing JSON output. Any value of an element which needs to be processed, is passed to type converter as a string (e&lt;SPAN style="font-size: 13.3333px;"&gt;ven if underlying type for the element according to XML document's XSD schema is not string, but integer or something else)&lt;/SPAN&gt;. Default type converter used by Jettison removes double quotes for values that are numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to instruct Jettison to use another type converter by setting corresponding value to a Java system property &lt;STRONG style="font-size: 10pt;"&gt;jettison.mapped.typeconverter.class&lt;/STRONG&gt;. For example, if you set value of this property to &lt;STRONG style="font-size: 10pt;"&gt;org.codehaus.jettison.mapped.SimpleConverter&lt;/STRONG&gt; (default type converter is &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;org.codehaus.jettison.mapped.DefaultConverter&lt;/STRONG&gt;&lt;/SPAN&gt;), Jettison will produce values surrounded by double quotes in an output. But this will mean that even if XML document contains an element of type integer, its value in JSON output will be surrounded by double quotes, too - which means, all element values will be surrounded by double quotes despite their type (referring to earlier statement that it Jettison doesn't perform check of element type as per XSD schema of the original XML document).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also develop and deploy your own type converter class (which should implement an interface org.codehaus.jettison.mapped.TypeConverter, method convertToJSONPrimitive()) and make use of it by Jettison if you need some advanced logic when producing elements values in JSON output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Java system property can be set/changed using NetWeaver Administrator: Configuration &amp;gt; Infrastructure &amp;gt; Java System Properties &amp;gt; tab "System VM Parameters" (instance restart is needed in order for change to take effect).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vadim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Dec 2015 13:42:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427433#M4247028</guid>
      <dc:creator>vadimklimov</dc:creator>
      <dc:date>2015-12-03T13:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427434#M4247029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vadim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am on SAP PI 7.4 SP 11. I searched in the System VM parameters but could not find the name you suggested. I even searched in the Advanced VM parameters but there also I didn't see this property.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/844695" width="450" /&gt;&lt;/P&gt;&lt;P&gt;Somebody suggested to use transform bean but this is for received REST adapter whereas mine is on the sender side.&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="3813588" __jive_macro_name="thread" class="jive_macro_thread jive_macro" data-orig-content="REST Receiver adapter XML to JSON conventer Problems number value - SF LMS" href="https://community.sap.com/" modifiedtitle="true" title="REST Receiver adapter XML to JSON conventer Problems number value - SF LMS"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Dec 2015 19:40:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427434#M4247029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-12-03T19:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427435#M4247030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Ravijeet, you need to add this parameter manually in the tab "System VM Parameters" (button "Add" on the screen you provided). Don't forget to save changes in NWA and restart an application server instances afterwards - otherwise changes will not take effect.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Vadim&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Dec 2015 19:46:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427435#M4247030</guid>
      <dc:creator>vadimklimov</dc:creator>
      <dc:date>2015-12-03T19:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427436#M4247031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vadim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you had stated earlier this property sets all values as string. I have decimals which now got converted as strings. So I would need to develop a java class and deploy that ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Also I am facing another problem, that we have an Array-like Element in the Repsonse XML DataType. Depending on the amount of actual elements in the array, the element gets converted to a JSON Array or JSON Object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;E.g. If the element contains exactly 1 item, it is converted to a JSON object. If it contains more than one item, it is converted to an array. if it contains no elements, it is not contained in JSON at all.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Regards&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 08:41:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427436#M4247031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-12-04T08:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427437#M4247032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vadim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you enhance this class and how you deploy it. Do we deploy it on J2ee server as an EAR file ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 18:01:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427437#M4247032</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-12-04T18:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427438#M4247033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN style="color: #333333; font-size: 12px;"&gt;Ravijeet,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Behaviour that you describe, is specifics of Jettison JSON processor: for example, if the array consists of only one element, most likely Jettison will not recognize it to be an array, but will qualify it as a complex object with a nested structure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Regarding custom type converter class. It is not a common practice to make such an enhancement, but considering Jettison employs type converter and can be extended with custom classes and REST adapter calls Jettison for XML/JSON conversion, it is necessary to ensure corresponding developed class is deployed and loaded properly, before or at a time of REST adapter invocation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vadim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 21:11:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427438#M4247033</guid>
      <dc:creator>vadimklimov</dc:creator>
      <dc:date>2015-12-04T21:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427439#M4247034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vadim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You mentioned &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;You may also develop and deploy your own type converter class (which should implement an interface org.codehaus.jettison.mapped.TypeConverter, method convertToJSONPrimitive()) and make use of it by Jettison if you need some advanced logic when producing elements values in JSON output.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;So I would need to write this class but how do I deploy this class ? Or do I go with an adapter module approach ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;I see we can use Moxy for this use case. &lt;A href="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html" title="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html"&gt;Java XML and JSON Binding: MOXy as Your JAX-RS JSON Provider - MOXyJsonProvider&lt;/A&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Not sure how to implement this.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Can I just use Jackson for the response in the java mapping and instruct the sender rest adapter not to do any xml to json conversion ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Thanks &lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Ravijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 21:33:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427439#M4247034</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-12-04T21:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: REST JSON Response</title>
      <link>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427440#M4247035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try to assemble a developed class into a library and deploy a custom library to an application server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using JSON format in response message instead of XML is feasible, but in this case JSON response will be handled by REST adapter as an unstructured text. So if you construct required JSON message in a form that is compliant to both JSON structure and your expectations on earlier stage of message processing in PO, it should work. Give a try and test it - for example, when preparing string with JSON message in a response mapping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vadim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:16:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/rest-json-response/qaa-p/11427440#M4247035</guid>
      <dc:creator>vadimklimov</dc:creator>
      <dc:date>2015-12-04T22:16:54Z</dc:date>
    </item>
  </channel>
</rss>

