All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.package-info Maven / Gradle / Ivy

There is a newer version: 3.2.0-9
Show newest version
/**
Basic data binding (mapping) functionality that
allows for reading JSON content into Java Objects (POJOs)
and JSON Trees ({@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.JsonNode}), as well as
writing Java Objects and trees as JSON.
Reading and writing (as well as related additional functionality) is accessed through
{@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper},
{@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectReader} and
{@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectWriter}
 classes.
 In addition to reading and writing JSON content, it is also possible to use the
 general databinding functionality for many other data formats, using
 Jackson extension modules that provide such support: if so, you typically
 simply construct an {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper} with
 different underlying streaming parser, generator implementation.

The main starting point for operations is {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper}, which can be used either directly (via multiple overloaded readValue, readTree, writeValue and writeTree methods, or it can be used as a configurable factory for constructing fully immutable, thread-safe and reusable {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectReader} and {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectWriter} objects.

In addition to simple reading and writing of JSON as POJOs or JSON trees (represented as {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.JsonNode}, and configurability needed to change aspects of reading/writing, mapper contains additional functionality such as:

  • Value conversions using {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper#convertValue(Object, Class)}, {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper#valueToTree(Object)} and {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper#treeToValue(io.prestosql.hadoop.$internal.com.fasterxml.jackson.core.TreeNode, Class)} methods.
  • Type introspection needed for things like generation of Schemas (like JSON Schema, Avro Schema, or protoc definitions), using {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper#acceptJsonFormatVisitor(Class, io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper)} (note: actual handles are usually provided by various Jackson modules: mapper simply initiates calling of callbacks, based on serializers registered)

Simplest usage is of form:

  final ObjectMapper mapper = new ObjectMapper(); // can use static singleton, inject: just make sure to reuse!
  MyValue value = new MyValue();
  // ... and configure
  File newState = new File("my-stuff.json");
  mapper.writeValue(newState, value); // writes JSON serialization of MyValue instance
  // or, read
  MyValue older = mapper.readValue(new File("my-older-stuff.json"), MyValue.class);

  // Or if you prefer JSON Tree representation:
  JsonNode root = mapper.readTree(newState);
  // and find values by, for example, using a {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.core.JsonPointer} expression:
  int age = root.at("/personal/age").getValueAsInt(); 

For more usage, refer to {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectMapper}, {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectReader} and {@link io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind.ObjectWriter} Javadocs. */ package io.prestosql.hadoop.$internal.com.fasterxml.jackson.databind;





© 2015 - 2024 Weber Informatics LLC | Privacy Policy