Jackson Method Detailed 您所在的位置:网站首页 @jsonautodetect Jackson Method Detailed

Jackson Method Detailed

#Jackson Method Detailed| 来源: 网络整理| 查看: 265

@

table of Contents First, introduction Second, dependence Third, ObjectMapper One), get JAVA objects from JSON 1. Simple example 2, ObjectMapper how to match the field of the JSON object and the properties of the Java object 3, JSON string -> java object 3, JSON Character Enterprise -> Java object 4, json file -> java object 5, JSON VIA URL ---> Java object 6, JSON byte input stream -> java object 7, JSON binary array -> java object 8, JSON array string -> Java object array 9, JSON array string -> list 10, JSON string -> MAP 11, ignore unknown JSON fields 12, do not allow basic types of null 13, custom deserialization 2) Write objects to JSON 1, Java object -> json 2, custom serialization 3) Jackson Date Transformation 1、Date-->long 2、Date-->String 4) Jackson JSON Tree Model 1, Jackson Tree Model simple example 2, Jackson JsonNode class 3, Java object -> jsonnode 4, JSONNODE -> Java object Four, jsonnode 1、JsonNode vs ObjectNode 2、JSON-->JsonNode 3、JsonNode-->JSON 4, get JSONNODE fields 5, get JSONNODE fields in the path 6, convert JSONNODE field 7. Create an ObjectNode 8, set objectNode field 9, Put ObjectNode field 10, delete fields 11, loop JSONNODE field V. JSONPARSER 1. Create a JSONPARSER 2, transform JSON with JSONPARSER JSONGENERATOR 1. Create a JSongenerator 2, generate JSON using JSongenerator 3, close JSongenerator 7. Jackson annotation A), Read + Write annotation 1、@JsonIgnore 2、@JsonIgnoreProperties 3、@JsonIgnoreType 4、@JsonAutoDetect 2), read annotation 1、@JsonSetter 2、@JsonAnySetter 3、@JsonCreator 4、@JacksonInject 5、@JsonDeserialize 3), WRITE annotation 1、@JsonInclude 2、@JsonGetter 3、@JsonAnyGetter 4、@JsonPropertyOrder 5、@JsonRawValue 6、@JsonValue 7、@JsonSerialize

Spring MVC defaults to Jackson parsing JSON, although there are other equally excellent JSON parsing tools, such as FAST JSON, GSON, but for minimal dependent consideration, maybe JSON parsing the first choice should be Jackson.

First, introduction

Jackson is a relatively widely used, an open source framework for serializing and deserializing JSON's JAVA. The Jackson community is relatively active, and the update is faster. From GitHub's statistics, Jackson is one of the most popular JSON parsers. The default JSON parser for Spring MVC is Jackson. Jackson has a lot of advantages. JAR bags dependent on Jackson are simple and easy to use. Compared to other Java's JSON frame GSON, Jackson parsing large JSON file speed is relatively fast; Jackson runs more memory, performance is better; Jackson has a flexible API, which can easily expand and customize.

Jackson's 1.x version of the package name is org.codehaus.jackson, when upgrading to a 2.x version, the package name is com.fasterxml.jackson.

Jackson's core module consists of three parts.

Jackson-Core, core package provides related APIs based on "stream mode", including JsonPaser and JSonGenerator. Jackson Internal Implementation is generated and parsing JSON in JSongenerator and JsonParser through high-performance stream mode API. Jackson-annotations, annotation package, standard annotation function; Jackson-Database, data binding package, providing "object binding" related API (ObjectMapper) and "tree model" parsing related API (JSONNODE); based on "object binding" resolution API and "tree model" The parsed API relies on the API based on "flow mode".

Source address:FasterXML/jackson

Second, dependence

Using the Maven build project, you need to add dependencies:

com.fasterxml.jackson.core jackson-core 2.9.6 com.fasterxml.jackson.core jackson-annotations 2.9.6 com.fasterxml.jackson.core jackson-databind 2.9.6

Of course, Jackson-Database relies on Jackson-Core and Jackson-Annotations, so you can add Jackson-Database, Jackson-Core and Jackson-Annotations, also added to the Java project project.

com.fasterxml.jackson.core jackson-databind 2.9.6

Here is Jackson's usage.

Third, ObjectMapper

Jackson's most common API is based on ObjectMapper based on object binding.

ObjectMapper can parse JSON from strings, streams, or files and create a Java object indicating that the parsed JSON. Eliminate JSON to Java objects, also known as the JSON Anti-sequence Java object.

ObjectMapper can also create JSON from Java objects. Generating JSON from Java objects is also known as Java object sequence as JSON.

The Object Map can parse JSON to a custom class object, or you can analyze the objects of the JSON tree model.

The reason why ObjectMapper is because it maps JSON to Java objects (reverse sequence), or maps Java objects to JSON (serialization).

One), get JAVA objects from JSON 1. Simple example

A simple example:

CAR class:

public class Car { private String brand = null; private int doors = 0; public String getBrand() { return this.brand; } public void setBrand(String brand){ this.brand = brand;} public int getDoors() { return this.doors; } public void setDoors (int doors) { this.doors = doors; } }

Convert JSON to a CAR class:

ObjectMapper objectMapper = new ObjectMapper(); String carJson ="{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; try { Car car = objectMapper.readValue(carJson, Car.class); System.out.println("car brand = " + car.getBrand()); System.out.println("car doors = " + car.getDoors()); } catch (IOException e) { e.printStackTrace(); } 2, ObjectMapper how to match the field of the JSON object and the properties of the Java object

By default, Jackson matches the JSON field with the Getter and Setter methods in the JAVA object, map the fields of the JSON object to the properties in the Java object. Jackson deletes the "GET" and "Set" section of the getter and setter method name, and converts the first character of the remaining name to lowercase.

For example, a JSON field named BRAND matches the Java Getter and Setter method named GetBrand () and setbrand (). The JSON field named enginenumber will match GetTER and SETTER named GetEnginenumber () and setEnginenumber ().

If you need to match the JSON object field to the Java object field, you need to use a custom sequencer and a deserializer or use some Jackson annotations.

3, JSON string -> java object

Reading Java objects from JSON strings is very easy. There is an example -JSON string that has been passed as the first parameter to ObjectMapper's ReadValue () method. This is another simple example:

ObjectMapper objectMapper = new ObjectMapper(); String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; Car car = objectMapper.readValue(carJson, Car.class); 3, JSON Character Enterprise -> Java object

You can also read objects from JSON loaded through Reader instances. Examples are as follows:

ObjectMapper objectMapper = new ObjectMapper(); String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 4 }"; Reader reader = new StringReader(carJson); Car car = objectMapper.readValue(reader, Car.class); 4, json file -> java object

Of course, you can be done by FileReader (not StringReader), or you can do it through the File object. This is an example of reading JSON from a file:

ObjectMapper objectMapper = new ObjectMapper(); File file = new File("data/car.json"); Car car = objectMapper.readValue(file, Car.class); 5, JSON VIA URL ---> Java object

You can read objects from JSON from JSON (java.net.ur) as follows:

ObjectMapper objectMapper = new ObjectMapper(); URL url = new URL("file:data/car.json"); Car car = objectMapper.readValue(url, Car.class);

The example uses the file URL, or HTTP URL (similar to http://jenkov.com/some-data.json).

6, JSON byte input stream -> java object

You can also read objects from JSON from JSON using ObjectMapper via InputStream. This is an example of reading JSON from InputStream:

ObjectMapper objectMapper = new ObjectMapper(); InputStream input = new FileInputStream("data/car.json"); Car car = objectMapper.readValue(input, Car.class); 7, JSON binary array -> java object

Jackson also supports reading objects from the JSON byte array. This is an example of reading an object from a JSON byte array:

ObjectMapper objectMapper = new ObjectMapper(); String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; byte[] bytes = carJson.getBytes("UTF-8"); Car car = objectMapper.readValue(bytes, Car.class); 8, JSON array string -> Java object array

Jackson ObjectMapper can also read an object array from the JSON array string. This is an example of reading an array from the JSON array string:

String jsonArray = "[{\"brand\":\"ford\"}, {\"brand\":\"Fiat\"}]"; ObjectMapper objectMapper = new ObjectMapper(); Car[] cars2 = objectMapper.readValue(jsonArray, Car[].class);

The CAR array class is required to be passed to the ReadValue () method as the second parameter.

The read object array can also be used with other JSON sources other than the string. For example, files, url, inputstream, reader, etc.

9, JSON array string -> list

Jackson ObjectMapper can also read Java LISTs from the JSON array string. This is an example of reading an object list from a JSON array string:

String jsonArray = "[{\"brand\":\"ford\"}, {\"brand\":\"Fiat\"}]"; ObjectMapper objectMapper = new ObjectMapper(); List cars1 = objectMapper.readValue(jsonArray, new TypeReference(){}); 10, JSON string -> MAP

Jackson ObjectMapper can also read Java Map from the JSON string. This method is useful if you don't know the exact JSON structure that will be parsed in advance. Often, JSON objects will be read into Java Map. Each field in the JSON object will be the key in Java Map, value pair.

This is an example of using Jackson ObjectMapper from the JSON string to read Java Map:

String jsonObject = "{\"brand\":\"ford\", \"doors\":5}"; ObjectMapper objectMapper = new ObjectMapper(); Map jsonMap = objectMapper.readValue(jsonObject, new TypeReference(){}); 11, ignore unknown JSON fields

Sometimes, the fields in JSON are more than the JAVA objects you want to read from JSON. By default, Jackson will throw an exception in this case, and the newspaper does not know the XYZ field exception because this field cannot be found in the Java object.

However, sometimes the fields in JSON are more than fields in the corresponding Java objects. For example, to resolve JSON from REST services, the data contained in the REST service is far exceeded. In this case, you can use the Jackson configuration to ignore these additional fields. The following is an example in which the Jackson ObjectMapper ignores unknown fields:

objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 12, do not allow basic types of null

If the JSON string contains a field set to NULL (for fields of basic data types (int, long, float, double) in the corresponding Java object), Jackson ObjectMapper defaults to handle basic data types NULL We can configure Jackson ObjectMapper to confirm in failure, so that basic data is NULL to fail. For example, the following CAR class:

public class Car { private String brand = null; private int doors = 0; public String getBrand() { return this.brand; } public void setBrand(String brand){ this.brand = brand;} public int getDoors(){ return this.doors; } public void setDoors (int doors) { this.doors = doors; } }

The DOORS field is an int type, which is the basic data type in Java.

Now, assume that there is a JSON string corresponding to the Car object, as shown below:

{ "brand":"Toyota", "doors":null }

Note that the DOORS field value is NULL. The basic data type in Java cannot be a NULL value. By default, Jackson ObjectMapper ignores null values ​​for the original field. However, you can set the Jackson ObjectMapper configuration to fail.

ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true);

In the case where the FAIL_ON_NULL_FOR_PRIMIVES configuration value is set to True, attempt to resolve an empty JSON field to the basic type Java field will encounter an exception. This is a Java Jackson ObjectMapper example that will fail because the JSON field contains an empty value of the original Java field:

ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true); String carJson = "{ \"brand\":\"Toyota\", \"doors\":null }"; Car car = objectMapper.readValue(carJson, Car.class);

result:

13, custom deserialization

Sometimes, you may want to read JSON strings into Java objects in a different way than Jackson ObjectMapper. The custom reverse sequencer can be added to the ObjectMapper, which can be performed as needed.

This is the way in Jackson's ObjectMapper registers and uses custom reverse sequencer:

String json = "{ \"brand\" : \"Ford\", \"doors\" : 6 }"; SimpleModule module = new SimpleModule("CarDeserializer", new Version(3, 1, 8, null, null, null)); module.addDeserializer(Car.class, new CarDeserializer(Car.class)); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module); Car car = mapper.readValue(json, Car.class);

Custom Deserializer CARDSERIALIZER Class:

public class CarDeserializer extends StdDeserializer { public CarDeserializer(Class vc) { super(vc); } @Override public Car deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { Car car = new Car(); while(!parser.isClosed()){ JsonToken jsonToken = parser.nextToken(); if(JsonToken.FIELD_NAME.equals(jsonToken)){ String fieldName = parser.getCurrentName(); System.out.println(fieldName); jsonToken = parser.nextToken(); if("brand".equals(fieldName)){ car.setBrand(parser.getValueAsString()); } else if ("doors".equals(fieldName)){ car.setDoors(parser.getValueAsInt()); } } } return car; } } 2) Write objects to JSON 1, Java object -> json

Jackson ObjectMapper can also be used to generate JSON from objects. You can use one of the following methods:

writeValue() writeValueAsString() writeValueAsBytes()

This is an example of generating JSON from a Car object, and the instance above:

ObjectMapper objectMapper = new ObjectMapper(); Car car = new Car(); car.setBrand("BMW"); car.setDoors(4); objectMapper.writeValue( new FileOutputStream("data/output-2.json"), car);

This example first creates an ObjectMapper and then creates a Car instance and finally calls the ObjectMapper's WriteValue () method converts the Car object to JSON and writes it to a given FileoutPutStream.

ObjectMapper's WriteValueAsstring () and WriteValueasBytes () generate JSON from an object and returns the generated JSON as a string or byte array. Examples are as follows:

ObjectMapper objectMapper = new ObjectMapper(); Car car = new Car(); Car.setbrand ("BMW"); car.setDoors(4); String json = objectMapper.writeValueAsString(car); System.out.println(json);

operation result:

2, custom serialization

Sometimes, you want to use Java object sequence to json to use Jackson's default way. For example, you might want to use different field names in JSON, or you want to completely omit certain fields.

Jackson can set a custom sequencer on ObjectMapper. This serializer has been registered for a class and then calls the serializer each time the ObjectMapper serialization Car object is required.

This is an example of registering a custom sequencer for a CAR class:

CarSerializer carSerializer = new CarSerializer(Car.class); ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule("CarSerializer", new Version(2, 1, 3, null, null, null)); module.addSerializer(Car.class, carSerializer); objectMapper.registerModule(module); Car car = new Car(); car.setBrand("Mercedes"); car.setDoors(5); String carJson = objectMapper.writeValueAsString(car);

Custom Series Carserializer Class:

public class CarSerializer extends StdSerializer { protected CarSerializer(Class t) { super(t); } public void serialize(Car car, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("producer", car.getBrand()); jsonGenerator.writeNumberField("doorCount", car.getDoors()); jsonGenerator.writeEndObject(); } }

operation result:

3) Jackson Date Transformation

By default, Jackson seizes the java.util.date object to its LONG type, which is the number of milliseconds since January 1, 1970. However, Jackson also supports formatting the date as a string.

1、Date-->long

The default Jackson date format, this format seizes DATE sequence to a millisecond (long type) since January 1, 1970.

This is an example of a Java class containing the Date field:

private String type = null; private Date date = null; public Transaction() { } public Transaction(String type, Date date) { this.type = type; this.date = date; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; }

Just like using other Java objects, the code is as follows:

Transaction transaction = new Transaction("transfer", new Date()); ObjectMapper objectMapper = new ObjectMapper(); String output = objectMapper.writeValueAsString(transaction); System.out.println(output);

operation result:

2、Date-->String

Date LONG serialization format does not conform to human hours view format. Therefore, Jackson also supports text date format. You can specify the exact Jackson date format to use by setting SimpleDateFormat on ObjectMapper. This is an example of setting SimpleDateFormat on Jackson's ObjectMapper:

Transaction transaction = new Transaction("transfer", new Date()); ObjectMapper objectMapper = new ObjectMapper(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); objectMapper.setDateFormat(dateFormat); String output2 = objectMapper.writeValueAsString(transaction); System.out.println(output2);

operation result:

4) Jackson JSON Tree Model

Jackson has a built-in tree model that can be used to represent a JSON object. If you don't know the format of the JSON received, or if you can't (or just don't want) to create a class, you will use the Jackson tree model. If you need to operate it before use or transform JSON, you also need to be used to use the Jackson tree model. All of these situations are common in data stream scenes.

The Jackson tree model is represented by the JSONNODE class. You can use Jackson ObjectMapper to resolve JSON as a JSONNode tree model, just like using your own class.

How to read and write JSONNode instances using Jackson ObjectMapper.

1, Jackson Tree Model simple example

Here is a simple example:

String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; ObjectMapper objectMapper = new ObjectMapper(); try { JsonNode jsonNode = objectMapper.readValue(carJson, JsonNode.class); } catch (IOException e) { e.printStackTrace(); }

Just deliver JSONNODE.CLASS as the second parameter to the ReadValue () method, rather than car.class used in the example of this tutorial, you can resolve the JSON string as a JSONNODE object instead of a Car object. .

The ObjectMapper class also has a special readtree () method that returns JsonNode. This is an example of using the ObjectMapper ReadTree () method to analyze JSON to JSONNode:

String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; ObjectMapper objectMapper = new ObjectMapper(); try { JsonNode jsonNode = objectMapper.readTree(carJson); } catch (IOException e) { e.printStackTrace(); } 2, Jackson JsonNode class

With JSONNODE classes, JSON can be navigated as a JSON object in a very flexible and dynamic manner. Here you understand some of the basics of using it.

Once JSON is parsed to JSONNODE (or JsonNode instance tree), you can browse the JSONNode tree model. This is an JSONNode example showing how to access JSON fields, arrays and nested objects:

String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5," + " \"owners\" : [\"John\", \"Jack\", \"Jill\"]," + " \"nestedObject\" : { \"field\" : \"value\" } }"; ObjectMapper objectMapper = new ObjectMapper(); try { JsonNode jsonNode = objectMapper.readValue(carJson, JsonNode.class); JsonNode brandNode = jsonNode.get("brand"); String brand = brandNode.asText(); System.out.println("brand = " + brand); JsonNode doorsNode = jsonNode.get("doors"); int doors = doorsNode.asInt(); System.out.println("doors = " + doors); JsonNode array = jsonNode.get("owners"); JsonNode jsonNode = array.get(0); String john = jsonNode.asText(); System.out.println("john = " + john); JsonNode child = jsonNode.get("nestedObject"); JsonNode childField = child.get("field"); String field = childField.asText(); System.out.println("field = " + field); } catch (IOException e) { e.printStackTrace(); }

Note that the JSON string now contains an array field called Owners and a nested object field called NestedObject.

Regardless of the field, the array is still a nested object, and the GET () method of the JSONNODE class can be used. You can access the field of JSONNODE by providing a string as a parameter to a get () method. If jsonnode represents an array, you need to pass the index to the get () method. Index Specifies the array elements to get.

3, Java object -> jsonnode

You can use Jackson ObjectMapper to convert Java objects to JSONNODE, while JsonNode is a JSON representation of the converted Java object. Java objects can be converted to JSONNODE through the Jackson ObjectMapper ValyETREE () method. This is an example of converting Java objects to JSONNode using ObjectMapper ValyETree () method:

ObjectMapper objectMapper = new ObjectMapper(); Car car = new Car(); car.brand = "Cadillac"; car.doors = 4; JsonNode carJsonNode = objectMapper.valueToTree(car); 4, JSONNODE -> Java object

You can use the Jackson ObjectMapper Treetovalue () method to convert JSONNODE to Java objects. This is similar to the ObjectMapper using Jackson Jackson to resolve the JSON string (or other source) into Java objects using JACKSON JACKSON. The only difference is that JSON sources are JSONNODE. This is an example of using the Jackson ObjectMapper Treetovalue () method to convert JSONNODE to Java objects:

ObjectMapper objectMapper = new ObjectMapper(); String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; JsonNode carJsonNode = objectMapper.readTree(carJson); Car car = objectMapper.treeToValue(carJsonNode);

The above example is a bit "artificial" because we first convert the JSON string to JSONNODE and convert JSONNODE to a Car object. Obviously, if we have a reference to the original JSON string, it is best to convert it directly to a Car object without having to convert it to JSONNODE.

Four, jsonnode

Jackson Jsonnode class com.fasterxml.jackson.dataBind.jsonnode is JACKSON JSON tree model (object map model). Jackson can read JSON to the JSONNode instance and write JSONNODE to JSON. Therefore, this section will explain how to define JSON inseparable sequences into JSONNODE and sequence JSONNODE sequence to JSON. This Jackson JsonNode tutorial will also explain how to build a JSONNode object map from scratch, so you can sequence into JSON later.

1、JsonNode vs ObjectNode

The Jackson JsonNode class is not variable. This means that the object map of the JSONNODE instance cannot be directly built. Instead, create an object map for JSONNODE sub-class ObjectNode. As a subclass of JSONNODE, ObjectNode can be used anywhere using JSONNODE.

2、JSON-->JsonNode

To use Jackson to read JSON to JsonNode, you first need to create a Jackson ObjectMapper instance. On the ObjectMapper instance, call ReadTree () and pass the JSON source as a parameter. This is an example of the reverse sequence of JSON to JSONNode:

String json = "{ \"f1\" : \"v1\" } "; ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(json); System.out.println(jsonNode.get("f1").asText()); 3、JsonNode-->JSON

To write Jackson's JSONNode, you need a Jackson ObjectMapper instance. On ObjectMapper, call the WriteValueAsstring () method or any write method suitable for need. This is an example of writing jsonnode into JSON:

ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = readJsonIntoJsonNode(); String json = objectMapper.writeValueAsString(jsonNode); 4, get JSONNODE fields

JsonNode can have a field like a JSON object. Suppose the following JSON is parsed to JSONNODE:

{ "field1" : "value1", "field2" : 999 }

This JSON object has two fields called Field1 and Field2. If there is a Jackson JsonNode that represents the above JSON object, you can get two fields:

JsonNode jsonNode = ... //parse above JSON into a JsonNode JsonNode field1 = jsonNode.get("field1"); JsonNode field2 = jsonNode.get("field2");

Note that even if both fields are string fields, the get () method always returns JSONNODE to represent the field.

5, get JSONNODE fields in the path

Jackson JsonNode has a special way known as at (). The AT () method can access the JSON field from any location of a given JSONNode from the JSON diagram. Suppose the JSON structure is as follows:

{ "identification" : { "name" : "James", "ssn: "ABC123552" } }

If you resolve this JSON to JSONNODE, you can use the AT () method to access the name field, as shown below:

JsonNode nameNode = jsonNode.at("/identification/name");

CAUTION Parameters passing to the AT () method: String / Identification / Name. This is a JSON path expression. This path expression specifies the full path from the root JSONNode to the field you want to access its value. This is similar to the path from the file system root directory to the file in the UNIX file system.

Note that JSON path expressions must begin with slash characters (/ characters).

The AT () method returns a JSONNode that represents the JSON field requested. To get the actual value of this field, you need to call one of the methods described in the next section. If no node matches a given path expression, the NULL will be returned.

6, convert JSONNODE field

The Jackson JSONNode class contains a group that can convert a field value to another data type. For example, convert the String field value to long or reverse. This is an example of converting the JSONNODE field to some more common data types:

String f2Str = jsonNode.get("f2").asText(); double f2Dbl = jsonNode.get("f2").asDouble(); int f2Int = jsonNode.get("f2").asInt(); long f2Lng = jsonNode.get("f2").asLong();

Conversion using the default value: If the field in JsonNode can be NULL, the default value can be provided when trying to convert it. This is an example of calling the conversion method using the default value:

ObjectMapper objectMapper = new ObjectMapper(); String json = "{ \"f1\":\"Hello\", \"f2\":null }"; JsonNode jsonNode = objectMapper.readTree(json); String f2Value = jsonNode.get("f2").asText("Default");

You can see in an example JSON string that declares the F2 field, but set it to NULL. In this case, call JSONNODE.GET ("F2"). Astext ("default") will return the default value, in this example, the string default.

askOUBLE (), asint () and aslong () methods can also use the default parameter value. If you try to get the value of the value is NULL, the default parameter value will be returned.

Note that if the field is not explicitly set to NULL in JSON, it is lost in JSON, then call JsonNode.get ("FieldName") will return Java Null value, you cannot call asint () on this Java value. askOUBLE (), aslong () or astext (). If you try to do this, it will cause nullpointerException. This is an example of this situation:

ObjectMapper objectMapper = new ObjectMapper(); String json = "{ \"f1\":\"Hello\" }"; JsonNode jsonNode = objectMapper.readTree(json); JsonNode f2FieldNode = jsonNode.get("f2"); 7. Create an ObjectNode

As mentioned earlier, the JSONNODE class is not variable. To create a JSONNODE object map, you must be able to change the JSONNode instance in the figure, such as setting the property value and sub-JSONNode instance, and so on. Since it is not changed, JsonNode cannot be used directly.

Instead, create an ObjectNode instance, which is a subclass of JSONNODE. This is an example of creating ObjectNode through the Jackson ObjectMapper CreateObjectNode () method:

ObjectMapper objectMapper = new ObjectMapper(); ObjectNode objectNode = objectMapper.createObjectNode(); 8, set objectNode field

To set a field on Jackson ObjectNode, you can call its set () method, and transfer the field name string and jsonnode as parameters. This is an example of setting fields on the ObjectNode of Jackson:

ObjectMapper objectMapper = new ObjectMapper(); ObjectNode parentNode = objectMapper.createObjectNode(); JsonNode childNode = readJsonIntoJsonNode(); parentNode.set("child1", childNode); 9, Put ObjectNode field

The ObjectNode class also has a group of methods that can be directly used for field PUT values. This is much easier than trying to convert the original value to JSONNODE and use set (). The following is an example of setting string values ​​using the PUT () method for fields on the field on ObjectNode:

objectNode.put("field1", "value1"); objectNode.put("field2", 123); objectNode.put("field3", 999.999); 10, delete fields

The ObjectNode class has a method called remove () that can be used to delete fields from ObjectNode. This is an example of deleting a field from Jackson ObjectNode from Jackson ObjectNode through its Remove () method:

objectNode.remove("fieldName"); 11, loop JSONNODE field

The JSONNode class has a method called FieldNames (), which returns an Iterator that iterates all the field names of JSONNODE. We can use the field name to get a field value. This is an example of all the field names and values ​​of iterative Jackson JsonNode:

Iterator fieldNames = jsonNode.fieldNames(); while(fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode field = jsonNode.get(fieldName); } V. JSONPARSER

The Jackson JsonParser class is a bottom-up JSON parser. It is similar to the XML Java Stax parser, and the difference is JsonParser parsing JSON without resolving XML.

Jackson JsonParser's run hierarchy is lower than Jackson ObjectMapper. This makes JsonParser faster than ObjectMapper, but it is more troublesome.

1. Create a JSONPARSER

To create Jackson JsonParser, you first need to create a JSONFACTORY. JsonFactory is used to create an JSONPARSER instance. The JSONFActory class contains several createParser () methods, each with different JSON sources as a parameter.

This is an example of creating a JSONPARSER to parse JSON from a string:

String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(carJson); 2, transform JSON with JSONPARSER

Once you have created Jackson JsonParser, you can use it to parse JSON. JSONPARSER's way to work is to break up JSON into a series of tokens, you can iterate a sign.

This is an JSONPARSER example, which simply loops over all tags and outputs them to system.out. This is an example of actually use, just demonstrating the token decomposed by JSON, and how to traverse the basics of the token.

tring carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(carJson); while(!parser.isClosed()){ JsonToken jsonToken = parser.nextToken(); System.out.println("jsonToken = " + jsonToken); }

As long as JsonParser's isclosed () method returns false, there will still be more tokens in JSON sources.

You can use JSonParser's nextToken () to get a JSONTOKEN. You can use this JSontoken instance to check the given token. The token type is represented by a set of constants in the JSontoken class. These constants are:

START_OBJECT END_OBJECT START_ARRAY END_ARRAY FIELD_NAME VALUE_EMBEDDED_OBJECT VALUE_FALSE VALUE_TRUE VALUE_NULL VALUE_STRING VALUE_NUMBER_INT VALUE_NUMBER_FLOAT

You can use these constants to find what type of token is current JSontoken. It can be operated by equals () methods of these constants. This is an example:

String carJson = "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }"; JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(carJson); Car car = new Car(); while(!parser.isClosed()){ JsonToken jsonToken = parser.nextToken(); if(JsonToken.FIELD_NAME.equals(jsonToken)){ String fieldName = parser.getCurrentName(); System.out.println(fieldName); jsonToken = parser.nextToken(); if("brand".equals(fieldName)){ car.brand = parser.getValueAsString(); } else if ("doors".equals(fieldName)){ car.doors = parser.getValueAsInt(); } } } System.out.println("car.brand = " + car.brand); System.out.println("car.doors = " + car.doors);

If the pointing tag is a field name, JsonParser's getCurrentName () method will return the current field name.

If the token pointing is a string field value, getValueAsstring () returns the current token value as a string. If the token pointing is an integer field value, getValueasint () returns the current token value as an int value. JsonParser has more similar ways to get different types of Curren token (such as Boolean, Short, long, float, double, etc.).

JSONGENERATOR

Jackson JSongenerator is used to generate JSON from Java objects (or any data structure from which JSONs from it).

1. Create a JSongenerator

To create Jackson JsonGenerator, you must first create a JSONFActory instance. This is a way to create JSONFACTORY:

JsonFactory factory = new JsonFactory();

Once you have created JSonFactory, you can create JSonGenerator using JSONFACTORY CREATEGENERATOR () method. This is an example of creating a JSongenerator:

JsonFactory factory = new JsonFactory(); JsonGenerator generator = factory.createGenerator( new File("data/output.json"), JsonEncoding.UTF8);

The first parameter of the CREATEGENERATOR () method is the target of the generated JSON. In the example above, the parameter is a File object. This means that the generated JSON will be written to a given file. The CreateGenerator () method has been overloaded, so there are other versions of the CreateGenerator () method, such as OutputStream, etc., provides different options that will be written to the generated JSON.

The second parameter of the CREATEGENERATOR () method is character encoding used when generating JSON. The example above uses UTF-8.

2, generate JSON using JSongenerator

Once you have created JSongenerator, you can start generating JSON. JSonGenerator includes a set of Write ... () methods that can use these methods to write a part of the JSON object. This is a simple example of generating JSON using Jackson JsonGenerator:

JsonFactory factory = new JsonFactory(); JsonGenerator generator = factory.createGenerator( new File("data/output.json"), JsonEncoding.UTF8); generator.writeStartObject(); generator.writeStringField("brand", "Mercedes"); generator.writeNumberField("doors", 5); generator.writeEndObject(); generator.close();

This example first calls WriteStartObject (), and writes the {write output. Then, the example calls WRITESTRINGFIELD (), and writes the brand field name + value. After that, the WriteNumberField () method will be called, which writes the DOORS field name + value to the output. Finally, call WriteEndObject (), write the output.

JSonGenerator can also use many other write methods. This example only shows some.

3, close JSongenerator

After completing JSON, you should close the JSonGenerator. You can implement it by calling its close () method. This is the way to close the JSongenerator:

generator.close(); 7. Jackson annotation

The Jackson JSON Toolkit contains a set of Java annotations that use these annotations to set the way to read the JSON to the object or what JSON is generated from the object. This Jackson annotation tutorial describes how to use Jackson's annotations.

Here are some commonly used annotations:

Notice Usage @JsonProperty For attributes, convert the name of the attribute to another name. Example: @JsonProperty("birth_ d ate") private Date birthDate; @JsonFormat For attributes or methods, transition to the specified format when serialize the properties. Example: @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm") public Date getBirthDate() @JsonPropertyOrder For class, specify the order in JSON when the properties are serialized, examples: @JsonPropertyOrder({ "birth_Date", "name" }) public class Person @JsonCreator For construction methods, and @jsonproperty use, there is a constructor with parameters. Example: @JsonCreator public Person(@JsonProperty("name")String name) {…} @JsonAnySetter For attributes or methods, setting unfolded sequenced attribute names and values ​​as key values ​​are stored in MAP @JsonAnySetter public void set(String key, Object value) { map.put(key, value); } @JsonAnyGetter For the method, get all the unprecedented properties public Map any() { return map; }

Here are some detailed descriptions of the annotations.

A), Read + Write annotation

Jackson contains a set of annotations that affect Java objects from JSON and write Java objects to JSON. I will refer to these annotations as "read + write annotations". The following sections will introduce Jackson's read and write annotations in more detail.

1、@JsonIgnore

Jackson annotation @jsonignore is used to tell Jackson to ignore an attribute (field) of the Java object. This property will be ignored when JSON is read into the Java object and writing Java objects to JSON.

This is an example using @jsonignore annotations:

import com.fasterxml.jackson.annotation.JsonIgnore; public class PersonIgnore { @JsonIgnore public long personId = 0; public String name = null; }

In the above class, JSON attribute Personid is not read or written from JSON.

2、@JsonIgnoreProperties

@JsonignoreProperties Jackson Note the list of properties used to specify the class to ignore. @JsonignoreProperties Note Place above the class declaration, not the individual properties to ignore (fields).

This is how this is an example of @JSonignoreProperties annotations:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties({"firstName", "lastName"}) public class PersonIgnoreProperties { public long personId = 0; public String firstName = null; public String lastName = null; }

In this example, the attribute firstname and lastname will be ignored because their names are listed in the @JsonignoreProperties annotation declaration above the class declaration.

3、@JsonIgnoreType

@JsonignoreType Jackson annotations are used to mark the entire type (class) as anywhere in this type will be ignored.

This is an example to show how to use @jsonignoreType:

import com.fasterxml.jackson.annotation.JsonIgnoreType; public class PersonIgnoreType { @JsonIgnoreType public static class Address { public String streetName = null; public String houseNumber = null; public String zipCode = null; public String city = null; public String country = null; } public long personId = 0; public String name = null; public Address address = null; }

In the example above, all Address instances will be ignored.

4、@JsonAutoDetect

Jackson annotations @jsonautodeTect is used to tell Jackson to include non-public modified properties when reading and writing objects.

This is an example class that shows how to use @jsonautodetect annotations:

import com.fasterxml.jackson.annotation.JsonAutoDetect; @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY ) public class PersonAutoDetect { private long personId = 123; public String name = null; }

The JSONAUTODETECT.Visibility class contains constants that match the visibility level in Java, indicating any, default, non_private, none, protected_and_private, and public_only.

2), read annotation

Jackson contains a set of annotations that only affect Jackson to resolve JSON to objects - means they affect JACKSON's readings for JSON. I call these "read solutions". The following sections describe Jackson's readings.

1、@JsonSetter

Jackson annotation @jsonsetter is used to tell Jackson, when reading the JSON into the object, the name of this setter method is matched to the attribute name in JSON data. If the attribute name inside the Java class is different from the attribute name used in the JSON file, this annotation is useful.

The following Person class corresponds to the field named ID in JSON with the Personid name:

public class Person { private long personId = 0; private String name = null; public long getPersonId() { return this.personId; } public void setPersonId(long personId) { this.personId = personId; } public String getName() { return name; } public void setName(String name) { this.name = name; } }

But in this JSON object, use the name ID instead of Personid:

{ "id" : 1234, "name" : "John" }

Jackson cannot map ID properties from the JSON object to the Personid field of the Java class.

@JsonSetter Note Indicates Jackson to use the setter method for a given JSON field. In our example, we add @JsonSetter annotations above the setPersonid () method.

This is an instance of adding @JsonSetter:

public class Person { private long personId = 0; private String name = null; public long getPersonId() { return this.personId; } @JsonSetter("id") public void setPersonId(long personId) { this.personId = personId; } public String getName() { return name; } public void setName(String name) { this.name = name; } }

The value specified in the @jsonsetter annotation is the name of the JSON field to match this setter method. In this case, the name is ID because this is the name of the field we want to map to the set of the setPersonid () setter method.

2、@JsonAnySetter

Jackson annotation @jsonanysetter indicates that Jackson invokes the same setter method for all unrecognized fields in the JSON object. "Unrecognizable" means all fields that have not been mapped to the property or setting method in the Java object.

Look at this BAG class:

public class Bag { private Map properties = new HashMap(); public void set(String fieldName, Object value){ this.properties.put(fieldName, value); } public Object get(String fieldName){ return this.properties.get(fieldName); } }

Then check this JSON object:

{ "id" : 1234, "name" : "John" }

Jackson cannot map the ID and NAME properties of this JSON object directly to the BAG class directly because the BAG class does not contain any common fields or setter methods.

You can tell Jackson to call the set () method for all unrecognized fields by adding @jsonanysetter annotations, as follows:

public class Bag { private Map properties = new HashMap(); @JsonAnySetter public void set(String fieldName, Object value){ this.properties.put(fieldName, value); } public Object get(String fieldName){ return this.properties.get(fieldName); } }

Now, Jackson calls the SET () method using all the names and values ​​of all those that cannot be identified in the JSON object.

Keep in mind that this is only valid for the unrecognized fields. For example, if you add a public name property or a setName (String) method to the BAG Java class, the name field in the JSON object will be changed to the presentation / setup.

3、@JsonCreator

Jackson annotation @jsoncreator is used to tell the Jackson that the Java object has a constructor ("Creater") that matches the field of the JSON object with the field of the Java object.

@JSONCREATOR Note is useful in the case where you cannot use @JsonSetter annotations. For example, a non-variable object does not have any setup methods, so they need to inject their initial values ​​into the constructor.

Take this Personimmutable class as an example:

public class PersonImmutable { private long id = 0; private String name = null; public PersonImmutable(long id, String name) { this.id = id; this.name = name; } public long getId() { return id; } public String getName() { return name; } }

To tell Jackson, you should call the constructor of the Personimmutable, we must add @JsonCreator annotations to the constructor. However, it is not enough for this. We must also annotate the parameters of the constructor to tell Jackson to pass which of the TSON objects is delivered to which constructor parameters.

Examples of the Personimmutable class adding @jsoncreator and @jsonproperty annotations are as follows:

public class PersonImmutable { private long id = 0; private String name = null; @JsonCreator public PersonImmutable( @JsonProperty("id") long id, @JsonProperty("name") String name ) { this.id = id; this.name = name; } public long getId() { return id; } public String getName() { return name; } }

Note that the annotations above the constructive function and the annotations before constructing the function parameters. Now, Jackson can create Personimmutable from this JSON object:

{ "id" : 1234, "name" : "John" } 4、@JacksonInject

Jackson annotation @JacksonInIect is used to inject values ​​into parsed objects instead of reading these values ​​from JSON. For example, suppose is downloading the Person JSON object from a variety of different sources, and wants to know which source is from a given Person object. The source itself may not contain this information, but the Jackson can be injected into the Java object created according to the JSON object.

To mark the fields in the Java class as a field that needs to be injected by Jackson, add @JacksonInJect annotations over this field.

This is an example of the PersoninJect class, add @JacksonInInJect annotations above attributes:

public class PersonInject { public long id = 0; public String name = null; @JacksonInject public String source = null; }

In order to let Jackson inject values ​​into properties, you need to do additional work when you create Jackson ObjectMapper.

This is the process of allowing Jackson to inject values ​​into the Java object:

InjectableValues inject = new InjectableValues.Std().addValue(String.class, "jenkov.com"); PersonInject personInject = new ObjectMapper().reader(inject) .forType(PersonInject.class) .readValue(new File("data/person.json"));

Note that how to set the value to be injected into the source property in the InjectableValues ​​AddValue () method. Also note that this value is only bound to string types - instead of binding to any particular field name. @JacksonInJect Note Specifies which field that is injected into the value.

If you want to download the person JSON object from multiple source, you must repeat the above code for each source for each source.

5、@JsonDeserialize

Jackson annotation @JsondSerialize specifies a custom reverse sequencer class for the properties given in the Java object.

For example, suppose to optimize the online format of the Boolean False and True to make it 0 and 1, respectively.

First, you need to add the @JSONDSERIALIALIZE annotation to the fields you want to use to use the custom reverse sequencer. This is an example of adding @JSONDSERIALIALIZE annotations to fields:

public class PersonDeserialize { public long id = 0; public String name = null; @JsonDeserialize(using = OptimizedBooleanDeserializer.class) public boolean enabled = false; }

Second, this is an instance of the OptimizedBooleandSerializer class referenced in the @JsondSerialize annotation:

public class OptimizedBooleanDeserializer extends JsonDeserializer { @Override public Boolean deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String text = jsonParser.getText(); if("0".equals(text)) return false; return true; } }

Note that the OptimizedBooleandSerializer class expands JSONDSERIALIZER using universal type Boolean. This will return the Deserialize () method to a Boolean object. If you want to deactivate other types (for example, java.util.date), you must specify this type in generic parentheses.

You can get the value of the field to be retrofitted by calling the GetText () method of the JsonParser parameter. Then, the text can be deactivated to any value, then enter the type for the reverse sequencer (the Boolean value in this example).

Finally, you need to view the format using a custom reverse sequencer and @JSONDSERIALIZER annotation of the reverse sequence object:

PersonDeserialize person = objectMapper .reader(PersonDeserialize.class) .readValue(new File("data/person-optimized-boolean.json"));

Note that we first need to create a reader using ObjectMapper's reader () method for the PersondEserialize class, then call ReadValue on the object returned by this method.

3), WRITE annotation

Jackson also contains a set of annotations that can affect JAVA objects (write) to JSON. The following sections describe each of these write (serialized) annotations.

1、@JsonInclude

Jackson annotation @JsonInClude tells Jackson only in some cases to include properties. For example, this property should only be included only if the property is non-NULL, non-empty or non-default. This is an example showing how to use @jsoninclude annotations:

import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_EMPTY) public class PersonInclude { public long personId = 0; public String name = null; }

If the value set for this example is non-empty, this example will only include the Name property, which means that not null and is not empty strings.

A more popular name of the @jsoninclude annotation should be @jsonincludenlywhen, but it will be longer.

2、@JsonGetter

@Jsongetter Jackson annotations to tell Jackson, you should get a field value by calling the getter method instead of direct field access. If your Java class uses the jQuery style getter and setter name, @jsongetter annotations are useful.

For example, you may have a method Personid () and Personid (LONG ID) instead of getPersonid () and setPersonid ().

This is an example class called PersongetTer, which shows the usage of @JSongetter annotations:

public class PersonGetter { private long personId = 0; @JsonGetter("id") public long personId() { return this.personId; } @JsonSetter("id") public void personId(long personId) { this.personId = personId; } }

As you can see, the personId () method comes with @jsongetter annotation. The value set on the @jsongetter annotation is the name that should be used in the JSON object. Therefore, the name of the Personid in the JSON object is ID. The generated JSON object is as follows:

{"id":0}

Also note that the Personid (Long Personid) is annotated using the @JsonSetter annotation so that Jackson identifies a setting method that matches the ID attribute in the JSON object. Use @jsonsetter annotations when reading JAVA objects from JSON - do not use Java objects to JSON. For complete, only @jsonsetter annotations are included.

3、@JsonAnyGetter

@JsonAnygetter Jackson Note allows you to use Map as a container that is sequenced as JSON's properties. This is an example of using the @JsonAnygetTer annotation in the Java class:

public class PersonAnyGetter { private Map properties = new HashMap(); @JsonAnyGetter public Map properties() { return properties; } }

When you see the @jsonanyget, Jackson will get the returned MAP from the method of @Jsonanyget, and treat each key value pair in the MAP as an attribute. In other words, all key value pairs in the map will serve as part of the Personanyget object to JSON.

4、@JsonPropertyOrder

@JSONPROPERTYORDER JACKSON annotations can be used to specify sequence of field sequences in Java objects into JSON. This is an example showing how to use the @JsonPropertyorder annotation:

@JsonPropertyOrder({"name", "personId"}) public class PersonPropertyOrder { public long personId = 0; public String name = null; }

Typically, Jackson will sequence the properties in the PersonPropertyOrder in the order found in the class. However, @ JsonPropertyOrder annotations specify different order, in serialized JSON output, the name attribute will appear first, and the Personid property will then appear.

5、@JsonRawValue

@JsonRawValue Jackson annotation tells Jackson This property value should be written directly into the JSON output. If this property is a string, Jackson usually enclose the value in quotation marks, but if you use the @JsonRawValue property, Jackson will not do this.

In order to know the role of @JsonRawValue, see this class without @JSonRawValue:

public class PersonRawValue { public long personId = 0; public String address = "$#"; }

Jackson will sequence its JSON string:

{"personId":0,"address":"$#"}

Now, we add @jsonrawvalue to the Address property, as shown below:

public class PersonRawValue { public long personId = 0; @JsonRawValue public String address = "$#"; }

Now, when serialization of the address properties, Jackson will omit quotation marks. Therefore, serialized JSON as follows:

{"personId":0,"address":$#}

Of course it is invalid JSON, then why do you do this?

If the address property contains a JSON string, the JSON string will be serialized to the final JSON object as part of the JSON object structure, not just a string in the Address field of the JSON object.

To see its working principle, let us change the value of the Address property like this:

public class PersonRawValue { public long personId = 0; @JsonRawValue public String address = "{ \"street\" : \"Wall Street\", \"no\":1}"; }

Jackson will sequence the following JSON:

{"personId":0,"address":{ "street" : "Wall Street", "no":1}}

Note that the JSON string now has a part of the serialization JSON structure.

No @jsonrawvalue annotation, Jackson will sequence the object as the following JSON:

{"personId":0,"address":"{ \"street\" : \"Wall Street\", \"no\":1}"}

Note that the value of the Address property is now caused by quotation marks, and all quotes within the value are essential.

6、@JsonValue

Jackson annotation @jsonvalue tells Jackson, Jackson should not attempt to serialize the object itself, but to call the object serialized as a JSON string on the object. Note that Jackson will transfine any quotes in the String of custom serialization, so, for example, a complete JSON object cannot be returned. To do this, @jsonrawvalue should be changed (see the previous section).

@JsonValue Note In the method added to Jackson calls to sequence the object sequence to the JSON string. This is an example showing how to use @JsonValue annotations:

public class PersonValue { public long personId = 0; public String name = null; @JsonValue public String toJson(){ return this.personId + "," + this.name; } }

The output obtained by the Jackson serialization Personvalue object is:

"0,null"

Quotation marks are added by Jackson. Remember that all quotes in the value returned by the object will escape.

7、@JsonSerialize

@JSonserialize Jackson Note Specify custom serialization programs for fields in the Java object. This is an example of a Java class using @jsonserialize annotations:

public class PersonSerializer { public long personId = 0; public String name = "John"; @JsonSerialize(using = OptimizedBooleanSerializer.class) public boolean enabled = false; }

Note the @Jsonserialize annotation above the field.

OptimizedBooleanSerializer seizes the true value of the sequence into 1, and seizes the false value into 0. This is the code:

public class OptimizedBooleanSerializer extends JsonSerializer { @Override public void serialize(Boolean aBoolean, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { if(aBoolean){ jsonGenerator.writeNumber(1); } else { jsonGenerator.writeNumber(0); } } }

reference:

【1】:Jackson Installation 【2】:Jackson ObjectMapper 【3】:High-end application of Jackson framework 【4】:Jackson JsonNode 【5】:Jackson JsonParser 【6】:Jackson JsonGenerator 【7】:Jackson Annotations



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有