0

There is a Rest service that produces JSON data. I was wondering what is an efficient way to parse the data into a Java POJO without the client being aware of the data that is coming in?

For example, I am aware that I can use Jackson with a predefined POJO class on the client so Jackson can generate the Object, however is there a framework available that can parse the JSON and create the POJO class as well?

The purpose is to maximize decoupling between client and Rest service.

The client will be a Java application.

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
Rami Del Toro
  • 1,130
  • 9
  • 24
  • Check http://stackoverflow.com/a/4480636/461807 – Hector Barbossa Jun 20 '16 at 23:22
  • 3
    Possible duplicate of [Generate Java class from JSON?](http://stackoverflow.com/questions/1957406/generate-java-class-from-json) – Hector Barbossa Jun 20 '16 at 23:24
  • @ Hector Barbossa I think jsonschema2pojo still needs the json schema to be placed in the build. I was wondering if there is a more dynamic way, without supplying a schema or a POJO to the client? I was thinking to not update all clients when the output of the Rest service will change. – Rami Del Toro Jun 20 '16 at 23:30
  • Even if you find a tool to do this, it won't help with your goal of decoupling the client and server; whenever the server changes you'll still need to regenerate your Java class. In my opinion a better approach would be to hand-craft your POJO and [ignore unknown properties](http://stackoverflow.com/a/7546047/611819) when deserializing. – dnault Jun 20 '16 at 23:39
  • "Not updating all clients when the output of the REST service changes" is pie in the sky. This will never be pragmatic, no mapper how many theses Roy Fielding writes. – dnault Jun 20 '16 at 23:41

0 Answers0