cancel
Showing results for 
Search instead for 
Did you mean: 

Jason Format issue using REST Adapter

venkatagiri_gongadi
Participant
0 Kudos

Hi All,

I am working on IDoc toJason format in PI7.31 SP15.I am facing issues below.

1.

actual Jason format:

{"data":{"id":"s123","types":11}}


Expected format:

{"data":[{"id":"s123","types":11}]}--How to achieve it?


2.Expected Jason format below  in case of multiple records ,i mean data has to repeat for each record.Is it possible?

{"data":[{"id":"s123","types":11}]},{"data":[{"id":"s123","types":11}]},{"data":[{"id":"s123","types":11}]}


Please provide some inputs on above.


Thanks,

Giri


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

This is an issue with the embedded JSON conversion of the REST adapter which should be fixed with the latest SP. You can follow up more details and a possible solution using an AM in this thread:

venkatagiri_gongadi
Participant
0 Kudos

Hi,

We have upgraded to SP17 but it is not populating data in [ ] for single record.


Does it work for any one?

Cheers,

Giri

venkatagiri_gongadi
Participant
0 Kudos

Hi All,

It worked for me ,Thanks for your help.

Cheers,

Giri

maheswarareddykonda
Active Contributor
0 Kudos

Has that resolved just by SP upgrade or you did some thing for that?

venkatagiri_gongadi
Participant
0 Kudos

Hi Mahesh,

After upgrade to SP17 ,we need to do following,

Tab  'Data Format', the table on the bottom 'Custom XML/JSON

Conversion rules":

Name=(Header node)

ArrayType=true

Cheers,

Giri

Answers (1)

Answers (1)

maheswarareddykonda
Active Contributor
0 Kudos

let me tell how rest adapter will convert xml to json format

if xml comes like

<?xml version="1.0" encoding="UTF-8" ?>

  <data>

  <id>s123</id>

  <types>11</types>

  </data>

output would be

{

  "data": {

    "id": "s123",

    "types": "11"

  }

}

if xml comes

<?xml version="1.0" encoding="UTF-8" ?>

  <data>

       <id>s123</id>

       <types>11</types>

  </data>

  <data>

       <id>s123</id>

       <types>11</types>

  </data>

  <data>

        <id>s123</id>

        <types>11</types>

  </data>

output would be

{

  "data": [

    {

      "id": "s123",

      "types": 11

    },

    {

      "id": "s123",

      "types": 11

    },

    {

      "id": "s123",

      "types": 11

    }

  ]

}

here you can observe one thing, when node comes multiple times then adapter will add those brackets [ ](in json we can say array)

so if your actual requirement as even after single  node comes you need array symbol , you can not achive this , you suppose to go some other option(something like java code)

also one work around i can suggest you, but not sure you have to check with REST server team if that OK with them.

here is the trick!

at target side structure i can see there is a node named as data

this node you can just duplicate in mapping and map with constant

since u node duplicated , you can see fields also under that data node, make sure you should not map anything for those fields.