Jackson Simple Data Binding: Difference between revisions
Jump to navigation
Jump to search
Line 15: | Line 15: | ||
Map root = on.readValue(inputStream, Map.class); | Map root = on.readValue(inputStream, Map.class); | ||
</pre> | |||
Most generically: | |||
<pre> | |||
Object root = mapper.readValue(src, Object.class); | |||
</pre> | </pre> | ||
Revision as of 19:16, 26 February 2017
Internal
Overview
Simple data binding extracts data from JSON and initializes a in-memory Java object hierarchy. Unlike the tree model, which uses JsonNodes, simple data binding uses Maps, Lists, Strings, Numbers, Booleans and nulls to represent the JSON structure.
ObjectMapper.readValue() must be called with a Map type and it will build a Map/List/String/Number/Boolean hierarchy:
import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper om = new ObjectMapper(); Map root = on.readValue(inputStream, Map.class);
Most generically:
Object root = mapper.readValue(src, Object.class);