java - Jersey - Moxy returning appended json in class property -


i have jersey client makes call 3rd party rest api , retrieves json.

{"a":1,"w":2,"list":[{"name":"john","amount":10.0}]} 

after need append json response class , give in response.

@xmlrootelement public class myresponse {      private jsonobject body;     private string status; 

i manage assign value comes 3rd party api body response that's sent this:

{ "status": "success", "body": { "entry": [   {   "key": "a",   "value": 1   }  ,   {   "key": "w",   "value": 2   },   {   "key": "list",   "value": "[{\"name\":\"john\",\"amount\":10.0}]"   } ] } } 

so there 2 main issues, moxy generating key , value elements while key: value , not generating 2nd level objects in json structure provided api.

moxy jaxb implementation, while jsonobject part of json-p. moxy happens able deal json too, proprietary extension on jaxb standard. far know, there no default mapping available between json-p , jaxb. reason you're seeing key/value entries must because jsonobject extends java.util.map, default moxy mapping type.

i think have following possibilities:

  1. go either json-p or jaxb/moxy (moxy required additional json binding) only.
  2. use 1 of jaxb/moxy mechanisms mapping custom types from/to jaxb. standard way use xmladapter, examples dealing maps in particular here , here. think difficult if don't know structure of 3rd party json content , want keep nested levels intact.

yet possibility might use proprietary api jackson, can't that.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -