JAX-RS: deserialization of org.json.JSONObject

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JAX-RS: deserialization of org.json.JSONObject

Kean Erickson
Although the javax.json.JsonObject API at is now meant to be used instead,
it's interesting that org.json.JSONObject is properly deserialized in
JAX-RS. The only catch is that every json object nested inside is itself
nested as a value with a key called "map", such that if I had a structure
like this:

"a" : { "b" : "c" }

...the resulting output would be:

"a" : { "map" : {"b": "c"} }

The org.simple.JSONObject library would be completely usable for this
purpose if not for this one strange addition. I'm wondering where this
behavior originates, or the simplest way to change it?

I'm aware that the json processing API is meant to be used instead, but I
find it to be fairly inflexible compared to JSONObject for a few reasons,
so I'd prefer to use the latter if possible.

Thanks,
-Kean
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS: deserialization of org.json.JSONObject

Romain Manni-Bucau
Hi Kean

You can write a message body reader/writer to handle org.json.


Le mar. 16 oct. 2018 20:50, Kean Erickson <[hidden email]> a
écrit :

> Although the javax.json.JsonObject API at is now meant to be used instead,
> it's interesting that org.json.JSONObject is properly deserialized in
> JAX-RS. The only catch is that every json object nested inside is itself
> nested as a value with a key called "map", such that if I had a structure
> like this:
>
> "a" : { "b" : "c" }
>
> ...the resulting output would be:
>
> "a" : { "map" : {"b": "c"} }
>
> The org.simple.JSONObject library would be completely usable for this
> purpose if not for this one strange addition. I'm wondering where this
> behavior originates, or the simplest way to change it?
>
> I'm aware that the json processing API is meant to be used instead, but I
> find it to be fairly inflexible compared to JSONObject for a few reasons,
> so I'd prefer to use the latter if possible.
>
> Thanks,
> -Kean
>