Suppose I have a data model like:
public class MyModel {
private String someString;
private String someJson; // Data structure owned by client, persisted as a CLOB
}
I'm serving the model via a REST API (Jersey) to a client. I know that I could marshal/unmarshal that to something like:
{
"someStrong": "foo",
"someJson": "{ someClientThing: \"bar\", someOtherClientThing: \"baz\"}"
}
But I'm looking for something cleaner. Is there a way that I can marshal/unmarshal that to JSON like this?
{
someStrong: "foo",
someJson: {
someClientThing: "bar",
someOtherClientThing: "baz"
}
}
I don't want the server to have to know about the data model for someJson
, as it's owned by the client. I just want the server to handle persistence of it - so the server would pass it back and forth between the client and database.
Note: It doesn't need to map directly to a string - as long as it can map to something unstructured (not statically defined on the server) that can be stringified before persistence (and unstringified back to that unstructured object on retrieval).