[User] JSON Array Cut in REST-BC

Dave Woodman dave at naffnet.org.uk
Wed May 20 15:26:35 BST 2020

Hello Edwin,

This behaviour is common with XML->JSON converters, both those found on-line
and in locally used code libraries. 

The problem is this - there is no 'array' in the JSON sense in XML, merely a
list of entries. If a converter sees an entry that does not repeat then it
renders it as a JSON object, since this is the simplest valid representation
that can be applied. 

If the XML contains repeated items (<item></item><item></item>) then
converters will render them as a JSON array, again since this would be the
simplest valid representation.

The converter is providing valid JSON in both of your use-cases, and is
therefore working. Unfortunately, there is more than one way to represent
the case of a single element, and the simplest representation is not the one
you are looking for.


-----Original Message-----
From: User <user-bounces at lists.open-esb.net> On Behalf Of edwin.agudelo via
Sent: 19 May 2020 13:19
To: user at lists.open-esb.net
Cc: edwin.agudelo <edwin.agudelo at gmail.com>
Subject: [User] JSON Array Cut in REST-BC


I work on a project that expose an REST API. In the definition I have a JSON
array. When the response have just one element the response not have the
JSON array form ([element]) but if have more elements the array is well

This is an example:

With one element:

"ordenDetalles": {
                    "idDetalle": 81,
                    "cantidadItem": 0,
                    "valor": 50000,
                    "idProducto": 3434

With more elements:

"ordenDetalles": [
                        "idDetalle": 482,
                        "cantidadItem": 0,
                        "valor": 0,
                        "idProducto": 1
                        "idDetalle": 483,
                        "cantidadItem": 0,
                        "valor": 0,
                        "idProducto": 4

I try to redefine the XML but not work.

Someone can said me what to do or what to change? 

First of all, Thanks.

*Note*: Sorry for my english.

Sent from: http://openesb-community-forum.794670.n2.nabble.com/

More information about the User mailing list