**I want to convert JSON into Java Pojo dynamically , meaning JSON structure will be change but I need to convert that JSON into Java Pojo without creating JSON POJO, is there any framework available ?
I thought about Dozzer mapper but in dozzer mapper I always need to create SRC Object POJO ,I need to avoid same.
**
2
Answers
Your question is too general. But here are few scenarios.
@JsonIgnoreProperties(ignoreUnknown = true)
annotation and the other properties in your JSON could be ignoredMap<String, Object>
that would be your only option.While you can use for your conversions Json-Jackson library or Gson library, I actually wrote my own wrapper over Jackson
ObjectMapper
class that may simplify this task for you. This feature comes as part of MgntUtils Open-Source java library written and maintained by me. Your code may look like:It throws IOException though so you will need to handle it. Here is the Javadoc. The MgntUtils library could be found as Maven artifact and on the Github (including javadoc and source code)
You can parse your json into a lightweight Json generic object provided by one of the Json libraries available that provide such a direct approach.
For instance essential-json (disclaimer – I’m the author), json-simple, json-java, …