cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi all,

Is there any way i can build an XML structure on SAP PI 7.5 and then convert it to JSON (using REST adapter) to generate this:

{  
   "Headers":[  
      "ID",
      "City",
      "Country"
   ],
   "Lines":[  
      [  
         12345,
         "NEWYORK",
         "USA"
      ],
      [  
         12346,
          "TORONTO",
         "CANADA"
      ],
      [  
         12347,
         "WASHINGTON",
         "USA"
      ]
   ]
}

this is the template of previous structure:

{  
   "Headers":[  
      "FieldName1",
      "FieldName2",
      "FieldName3"
   ],
   "Lines":[  
      [  
         FieldName1-Value1,
         FieldName2-"Value1",
         FieldName3-"Value1",
      ],
      [  
         FieldName1-Value2,
         FieldName2-"Value2",
         FieldName3-"Value2",
      ],
      [  
         FieldName1-Value3,
         FieldName2-"Value3",
         FieldName3-"Value3",
      ]
   ]
}

The problem is with the "Lines" structure. There is an array inside the array "Lines" but it has no name on it.

I was thinking to use JAVA mapping to generate it, but i prefer to use a standard way.

Thanks in advance.

0 Likes
View Entire Topic
former_member190293
Active Contributor

Hi Israel!

Looking at your template the first question is: how should respective XML structure for your JSON input look like, since you describe unnamed array inside your JSON?

Regards, Evgeniy.

Former Member
0 Likes

Hi Evgeniy,

That is the issue we have... the unnamed array.

This is the way we think to build the XML target structure.

When we send this to REST adapter, the Headers looks good but not the Lines.

{  
   "Headers":[  
      "ID",
      "City",
      "Country"
   ],
   "Lines":[  
      "12345,\"NEWYORK\",\"USA\"",
      "12346,\"TORONTO\",\"CANADA\"",
      "12347,\"WASHINGTON\",\"USA\""
   ]
}

Do you know how can we have the unnamed array inside lines?

Just as reference, this is the source Structure...