Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: JM Brun
Added: Mar 20, 2019 4:22 PM
Views: 18
Tags: no tags
  1. http://websystique.com/java/json/jackson-convert-java-object-to-from-json/
  2. //Read JSON and populate java objects
  3. ObjectMapper mapper = new ObjectMapper();
  4. Object value = mapper.readValue(JSON-SOURCE , DESTINATION-JAVA-OBJECT-TYPE);
  5. //JSON-SOURCE can be File/InputStream/String/etc..
  6.  
  7. //Write JSON from java objects
  8. ObjectMapper mapper = new ObjectMapper();
  9. Object value = mapper.writeValue(JSON-DESTINATION, SOURCE-JAVA-OBJECT);
  10. //JSON-DESTINATION can be File/InputStream/String/etc..