git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JSON Arrays


Hi guys

I have a few routes where I convert XML [or maybe SQL so java.util.ArrayList] to JSON objects. Depending on the original payload, I sometimes get:
{
   "someName":[
      {
         "key1":"value1"
      },
      {
         "key2":"value2"
      }
   ]
}

or if there's only one "key" it might be:
{
   "someName":{
      "key1":"value1"
   }
}

Consumers of these services have serialization issues when it comes to the fact that the keys aren't always arrays.

So my question has two parts:
a) Can I tell my data format to have some sort of "always make this an array" flag
and/ or
b) do you guy solve this by putting the first result into a POJO first?

or I guess:
c) am I missing the bulls-eye dramatically with my thinking, in which case suggestions are very welcome

Thanks
Riaan




( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03499.html on line 113
Call Stack
#TimeMemoryFunctionLocation
10.0007358376{main}( ).../msg03499.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03499.html on line 113
Call Stack
#TimeMemoryFunctionLocation
10.0007358376{main}( ).../msg03499.html:0