What if u use a multi value map? Or a map <String, String[]> or any othe
collectiin type in the value?
Just a thought.
On Sep 4, 2014 12:27 AM, "Everett Toews" <everett.to...@rackspace.com>
wrote:

> We have a situation uncovered by this issue [1] where the JSON response
> has different value types for String keys in a Map.
>
> For example,
>
> {
>   "images": [
>     {
>       "id": "cd9d57a9-0978-45f3-9cbc-edb99347be6b",
>       "metadata": {
>         "block_device_mapping": [
>           {
>             "snapshot_id": "a900a56c-61b7-4438-9150-76312fa1aa10",
>             "destination_type": "volume",
>             "delete_on_termination": null
>           }
>         ],
>         "checksum": "32c08d302f9206668030d47789b77858”,
>         ”some_key”: ”some_value”,
>       }
>     },
>     ….
> }
>
> This is handled by deserialization of this field in the Image domain
> object [2]. Because it’s a Map<String, String> it blows up with an
> exception when it hits the block_device_mapping, which is an array.
>
> IllegalStateException: Expected a string but was BEGIN_ARRAY
>
> Doing something like Map<String, Object> isn’t a great option as it forces
> the caller to constantly check for the type. 99% of the time it’s going to
> be Map<String, String> so it pains me to consider complicating the client
> code for this corner case.
>
> Any thoughts on how to gracefully handle this situation?
>
> Thanks,
> Everett
>
> [1] https://issues.apache.org/jira/browse/JCLOUDS-655
> [2]
> https://github.com/jclouds/jclouds/blob/master/apis%2Fopenstack-nova%2Fsrc%2Fmain%2Fjava%2Forg%2Fjclouds%2Fopenstack%2Fnova%2Fv2_0%2Fdomain%2FImage.java#L207

Reply via email to