Petals BC REST

Add support of JSON format 'ordered value list'

Details

  • Type: Improvement Request Improvement Request
  • Status: In Progress In Progress
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0.1-BC
  • Fix Version/s: None
  • Component/s: Provider mode
  • Security Level: Public
  • Description:
    Hide

    JSON is composed of two formats:

    • key/value list, as:
      {
          "key-A": {
              "subkey-A": "value-1",
              "subkey-B": "value-2"
          },
          "key-B": "value-3"
      }
    • and orderer value list, as:
      [
          [
              "value-1",
              "value-2"
          ],
          "value-3"
      ]

    So, please add support of format 'ordered value list'.

    Show
    JSON is composed of two formats:
    • key/value list, as:
      {
          "key-A": {
              "subkey-A": "value-1",
              "subkey-B": "value-2"
          },
          "key-B": "value-3"
      }
    • and orderer value list, as:
      [
          [
              "value-1",
              "value-2"
          ],
          "value-3"
      ]
    So, please add support of format 'ordered value list'.
  • Environment:
    -

Activity

Hide
Christophe DENEUX added a comment - Fri, 16 Jun 2017 - 15:55:37 +0200

Support of conversion XML --> JSON added

Show
Christophe DENEUX added a comment - Fri, 16 Jun 2017 - 15:55:37 +0200 Support of conversion XML --> JSON added
Hide
Christophe DENEUX added a comment - Fri, 16 Jun 2017 - 15:21:43 +0200

The JSON format 'ordered value list' seems to be not supported by genereric JSON<-->XML coverters, so we must find a way to convert it ourself:

  • XML --> JSON can be done using an XSL, and espacially the XSL used to adapt the incoming XML payload (PETALSBCREST-26). So, it is sufficient to add a configuration parameter to not apply XML to JSON conversion:
    <rest:operation name="mailService:setVacationSignature">
                   <rest:http-method>POST</rest:http-method>
                   <rest:http-body-type>JSON</rest:http-body-type>
                   <rest:uri>${openpaas.mail-api.base-url}</rest:uri>
                   ...
                   <rest:xsl is-json-result="true">set-vacation-signature.xsl</rest:xsl>
                   ...
                </rest:operation>
  • JSON --> XML can be done programmatically through a dedicated transformation type 'java' in which the JSON will be parsed, and XML will be generated:
    <rest:operation name="mailService:setVacationSignature">
                   <rest:http-method>POST</rest:http-method>
                   <rest:http-body-type>JSON</rest:http-body-type>
                   <rest:uri>${openpaas.mail-api.base-url}</rest:uri>
                   ...
                   <rest:on-http-status code="200">
                      <rest:otherwise-out>
                         <rest:transformation>
                            <rest:java>org.ow2.petals.samples.openpaas.technical.mail.OutTransformation</rest:java>
                         </rest:transformation>
                      </rest:otherwise-out>
                   </rest:on-http-status>
                </rest:operation>
Show
Christophe DENEUX added a comment - Fri, 16 Jun 2017 - 15:21:43 +0200 The JSON format 'ordered value list' seems to be not supported by genereric JSON<-->XML coverters, so we must find a way to convert it ourself:
  • XML --> JSON can be done using an XSL, and espacially the XSL used to adapt the incoming XML payload (PETALSBCREST-26). So, it is sufficient to add a configuration parameter to not apply XML to JSON conversion:
    <rest:operation name="mailService:setVacationSignature">
                   <rest:http-method>POST</rest:http-method>
                   <rest:http-body-type>JSON</rest:http-body-type>
                   <rest:uri>${openpaas.mail-api.base-url}</rest:uri>
                   ...
                   <rest:xsl is-json-result="true">set-vacation-signature.xsl</rest:xsl>
                   ...
                </rest:operation>
  • JSON --> XML can be done programmatically through a dedicated transformation type 'java' in which the JSON will be parsed, and XML will be generated:
    <rest:operation name="mailService:setVacationSignature">
                   <rest:http-method>POST</rest:http-method>
                   <rest:http-body-type>JSON</rest:http-body-type>
                   <rest:uri>${openpaas.mail-api.base-url}</rest:uri>
                   ...
                   <rest:on-http-status code="200">
                      <rest:otherwise-out>
                         <rest:transformation>
                            <rest:java>org.ow2.petals.samples.openpaas.technical.mail.OutTransformation</rest:java>
                         </rest:transformation>
                      </rest:otherwise-out>
                   </rest:on-http-status>
                </rest:operation>

People

Dates

  • Created:
    Fri, 16 Jun 2017 - 15:06:15 +0200
    Updated:
    Fri, 16 Jun 2017 - 15:55:37 +0200