This is similar to my post here...
JAXB Unmarshal JSON HTTP POST Parameters
Except in this case I need to unmarshal my JSON that not only contains the HTTP POST parameters but also an object. Consider the following JSON...
{
"client": "1",
"forTopic": "topic",
"MyObject":{
"name":"the name",
"id":1
}
}
client and forTopic are the HTTP POST parameters. MyObject is the object I'm trying to receive to act on. I'd like to pull the parameters separately from the object.
I can do this by setting up an object that contains 3 fields. Field 1 is a String for client. Field 2 is an int for id. Field 3 is MyObject theObject.
This allows me to pull everything fine. However I'd prefer not to have to create a "wrapper" class for each of my objects that has parameters. Is there a better/proper way to do this? Either by pulling the parameters out of the JSON and be left with the resulting JSON of MyObject to then unmarshal or somehow specify the depth to dig down into the JSON to unmarshal? The parameters are fairly consistent for each of my objects. I just don't want to have to create wrappers fo them all.
Perhaps another way to ask this is what is the proper approach to handle HTTP POST parameters contained in your JSON using JAXB/Moxy?
Edit :
For reference. Here are my relevant dependencies.
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
And my jaxb.properties...
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory