1 /** 2 Basic data binding (mapping) functionality that 3 allows for reading JSON content into Java Objects (POJOs) 4 and JSON Trees ({@link com.fasterxml.jackson.databind.JsonNode}), as well as 5 writing Java Objects and trees as JSON. 6 Reading and writing (as well as related additional functionality) is accessed through 7 {@link com.fasterxml.jackson.databind.ObjectMapper}, 8 {@link com.fasterxml.jackson.databind.ObjectReader} and 9 {@link com.fasterxml.jackson.databind.ObjectWriter} 10 classes. 11 In addition to reading and writing JSON content, it is also possible to use the 12 general databinding functionality for many other data formats, using 13 Jackson extension modules that provide such support: if so, you typically 14 simply construct an {@link com.fasterxml.jackson.databind.ObjectMapper} with 15 different underlying streaming parser, generator implementation. 16 <p> 17 The main starting point for operations is {@link com.fasterxml.jackson.databind.ObjectMapper}, 18 which can be used either directly (via multiple overloaded 19 <code>readValue</code>, 20 <code>readTree</code>, 21 <code>writeValue</code> and 22 <code>writeTree</code> methods, or it can be used as a configurable factory for constructing 23 fully immutable, thread-safe and reusable {@link com.fasterxml.jackson.databind.ObjectReader} 24 and {@link com.fasterxml.jackson.databind.ObjectWriter} objects. 25 <p> 26 In addition to simple reading and writing of JSON as POJOs or JSON trees (represented as 27 {@link com.fasterxml.jackson.databind.JsonNode}, and configurability needed to change aspects 28 of reading/writing, mapper contains additional functionality such as: 29 <ul> 30 <li>Value conversions using {@link com.fasterxml.jackson.databind.ObjectMapper#convertValue(Object, Class)}, 31 {@link com.fasterxml.jackson.databind.ObjectMapper#valueToTree(Object)} and 32 {@link com.fasterxml.jackson.databind.ObjectMapper#treeToValue(com.fasterxml.jackson.core.TreeNode, Class)} methods. 33 </li> 34 <li>Type introspection needed for things like generation of Schemas (like JSON Schema, Avro Schema, or protoc 35 definitions), using {@link com.fasterxml.jackson.databind.ObjectMapper#acceptJsonFormatVisitor(Class, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper)} 36 (note: actual handles are usually provided by various Jackson modules: mapper simply initiates calling of 37 callbacks, based on serializers registered) 38 </li> 39 </ul> 40 <p> 41 Simplest usage is of form: 42 <pre> 43 final ObjectMapper mapper = new ObjectMapper(); // can use static singleton, inject: just make sure to reuse! 44 MyValue value = new MyValue(); 45 // ... and configure 46 File newState = new File("my-stuff.json"); 47 mapper.writeValue(newState, value); // writes JSON serialization of MyValue instance 48 // or, read 49 MyValue older = mapper.readValue(new File("my-older-stuff.json"), MyValue.class); 50 51 // Or if you prefer JSON Tree representation: 52 JsonNode root = mapper.readTree(newState); 53 // and find values by, for example, using a {@link com.fasterxml.jackson.core.JsonPointer} expression: 54 int age = root.at("/personal/age").getValueAsInt(); 55 </pre> 56 <p> 57 For more usage, refer to 58 {@link com.fasterxml.jackson.databind.ObjectMapper}, 59 {@link com.fasterxml.jackson.databind.ObjectReader} and 60 {@link com.fasterxml.jackson.databind.ObjectWriter} 61 Javadocs. 62 */ 63 64 package com.fasterxml.jackson.databind; 65