In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Spring Boot supports integration with three JSON mapping libraries: Gson, Jackson, and JSON-B. Jackson is preferred and default.
Jackson is part of the spring-boot-starter-json dependency, and spring-boot-starter-web contains spring-boot-starter-json. That is, spring-boot-starter-json is automatically introduced when spring-boot-starter-web is introduced into the project.
Org.springframework.boot spring-boot-starter-webJacksonObjectMapper
ObjectMapper is a class in the jackson-databind package, which provides the ability to read and write JSON, and can easily convert objects and JSON:
Import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;import java.io.IOException;public final class JsonUtil {private static ObjectMapper mapper = new ObjectMapper (); private JsonUtil () {} / * * Serialize any Java value as a String. * / public static String generate (Object object) throws JsonProcessingException {return mapper.writeValueAsString (object);} / * * Deserialize JSON content from given JSON content String. * / public static T parse (String content, Class valueType) throws IOException {return mapper.readValue (content, valueType);}}
Write a simple POJO test class:
Import java.util.Date;public class Hero {private String name; private Date birthday; public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new Hero ("Jason", new Date ();} public Hero () {} public Hero (String name, Date birthday) {this.name = name; this.birthday = birthday } public String getName () {return name;} public Date getBirthday () {return birthday;}}
The output result after running is as follows:
{"name": "Jason", "birthday": 1540909420353} date conversion
In the above example, the default date is converted to a long integer.
The default serialization configuration of ObjectMapper enables SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, and the date is converted to Timestamp. You can view the following source codes:
Public ObjectMapper (JsonFactory jf, DefaultSerializerProvider sp, DefaultDeserializationContext dc) {... BaseSettings base = DEFAULT_BASE.withClassIntrospector (defaultClassIntrospector ()); _ configOverrides = new ConfigOverrides (); _ serializationConfig = new SerializationConfig (base, _ subtypeResolver, mixins, rootNames, _ configOverrides);...} public SerializationConfig (BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides) {super (base, str, mixins, rootNames, configOverrides); _ serFeatures = collectFeatureDefaults (SerializationFeature.class); _ filterProvider = null; _ defaultPrettyPrinter = DEFAULT_PRETTY_PRINTER; _ generatorFeatures = 0 _ generatorFeaturesToChange = 0; _ formatWriteFeatures = 0; _ formatWriteFeaturesToChange = 0;}
By default, Date type serialization calls the _ timestamp method of DateSerializer:
/ * For efficiency, we will serialize Dates as longs, instead of * potentially more readable Strings. * / @ JacksonStdImpl@SuppressWarnings ("serial") public class DateSerializer extends DateTimeSerializerBase {. @ Override protected long _ timestamp (Date value) {return (value = = null)? 0L: value.getTime ();} @ Override public void serialize (Date value, JsonGenerator g, SerializerProvider provider) throws IOException {if (_ asTimestamp (provider)) {g.writeNumber (_ timestamp (value)); return } _ serializeAsString (value, g, provider);}}
The _ asTimestamp method of DateTimeSerializerBase:
Protected boolean _ asTimestamp (SerializerProvider serializers) {if (_ useTimestamp! = null) {return _ useTimestamp.booleanValue ();} if (_ customFormat = = null) {if (serializers! = null) {return serializers.isEnabled (SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);} / 12-Jun-2014, tatu: Is it legal not to have provider? Was NPE:ing earlier so leave a check throw new IllegalArgumentException ("Null SerializerProvider passed for" + handledType (). GetName ();} return false;}
Disable WRITE_DATES_AS_TIMESTAMPS
To serialize the date into a string, disable SerializationFeature.WRITE_DATES_AS_TIMESTAMPS:
Mapper.disable (SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
At this point, the serialization will call the format () method of StdDateFormat, using the ISO-8601-compatible format "yyyy-MM-dd'T'HH:mm:ss.SSSZ". The output is as follows:
{"name": "Jason", "birthday": "2018-10-31T03:07:34.485+0000"}
StdDateFormat deserialization supports both ISO-8601 compatible format and RFC-1123 ("EEE, dd MMM yyyy HH:mm:ss zzz") format.
@ JsonFormat
Using @ JsonFormat annotations instead of global settings is a more flexible approach:
@ JsonFormat (shape = JsonFormat.Shape.STRING) private Date birthday
You can also define pattern:
@ JsonFormat (shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private Date birthday
When the pattern is customized, a new SimpleDateFormat instance is created to serialize the date, as shown in the createContextual () method of DateTimeSerializerBase:
Public JsonSerializer createContextual (SerializerProvider serializers, BeanProperty property) throws JsonMappingException {... If (format.hasPattern ()) {final Locale loc = format.hasLocale ()? Format.getLocale (): serializers.getLocale (); SimpleDateFormat df = new SimpleDateFormat (format.getPattern (), loc); TimeZone tz = format.hasTimeZone ()? Format.getTimeZone (): serializers.getTimeZone (); df.setTimeZone (tz); return withFormat (Boolean.FALSE, df);}.} Common Notes
However, to explain the role of the notes, please see the output results.
Example 1
Import com.fasterxml.jackson.annotation.JsonAlias;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;import com.fasterxml.jackson.annotation.JsonInclude;import com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonPropertyOrder ({"firstName", "lastName"}) @ JsonIgnoreProperties ({"id"}) @ JsonInclude (JsonInclude.Include.NON_NULL) public class Hero {private Integer id; / / define one or more alternative names for a property during deserialization @ JsonAlias ({"fName", "f_name"}) private String firstName; private String lastName; public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new Hero (1, "Jason", "Sun")); System.out.println (JsonUtil.generate (new Hero (1, "Jason", null) System.out.println (JsonUtil.parse ("{\" fName\ ":\" Jason\ ",\" lastName\ ":\" Sun\ "}, Hero.class). GetFirstName ();} public Hero () {} public Hero (Integer id, String firstName, String lastName) {this.id = id; this.firstName = firstName; this.lastName = lastName;} / / getter and setter}
Output result:
{"firstName": "Jason", "lastName": "Sun"} {"firstName": "Jason"} Jason
Example 2
Import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonIgnoreType;import com.fasterxml.jackson.annotation.JsonProperty;public class Hero {@ JsonIgnore private Integer id; private String nickname; private Name name; @ JsonProperty ("mail") private String email; @ JsonIgnoreType public static class Name {private String firstName; private String lastName; public Name (String firstName, String lastName) {this.firstName = firstName This.lastName = lastName;} / / getter and setter} public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new Hero (1, "chuanchuan", new Name ("Jason", "Sun"), "jason@163.com") } public Hero () {} public Hero (Integer id, String nickname, Name name, String email) {this.id = id; this.nickname = nickname; this.name = name; this.email = email;} / / getter and setter}
Output result:
{"nickname": "chuanchuan", "mail": "jason@163.com"}
Example 3
Use @ JsonValue to control the result of serialization of the entire class, and there can be at most one @ JsonValue in a class.
Import com.fasterxml.jackson.annotation.JsonValue;public class HeroWithValue {private Integer id; @ JsonValue private String name; private String email; public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new HeroWithValue (1, "Jason", "jason@163.com"));} public HeroWithValue (Integer id, String name, String email) {this.id = id; this.name = name This.email = email;} / / getter and setter}
Output result:
"Jason"
Example 4
Public class Views {public static class Public {} public static class Internal extends Public {} import com.fasterxml.jackson.annotation.JsonView;import com.fasterxml.jackson.databind.ObjectMapper;public class HeroWithView {@ JsonView (Views.Public.class) private int id; @ JsonView (Views.Public.class) private String name; @ JsonView (Views.Internal.class) private String email Public static void main (String [] args) throws Exception {HeroWithView hero = new HeroWithView (1, "Jason", "jason@163.com"); String publicResult = new ObjectMapper (). WriterWithView (Views.Public.class) .writeValueAsString (hero); String internalResult = new ObjectMapper (). WriterWithView (Views.Internal.class) .writeValueAsString (hero); System.out.println (publicResult); System.out.println (internalResult) } public HeroWithView (int id, String name, String email) {this.id = id; this.name = name; this.email = email;}}
Output result:
{"id": 1, "name": "Jason"} {"id": 1, "name": "Jason", "email": "jason@163.com"}
Example 5
Import com.fasterxml.jackson.annotation.JsonRootName;import com.fasterxml.jackson.annotation.JsonUnwrapped;import com.fasterxml.jackson.databind.ObjectMapper;import com.fasterxml.jackson.databind.SerializationFeature;@JsonRootName (value = "hero") public class UnwrappedHero {private int id; @ JsonUnwrapped private Name name; public static void main (String [] args) throws Exception {ObjectMapper mapper = new ObjectMapper (); mapper.enable (SerializationFeature.WRAP_ROOT_VALUE) System.out.println (mapper.writeValueAsString (new UnwrappedHero (1, new Name ("Jason", "Sun");} public UnwrappedHero (int id, Name name) {this.id = id; this.name = name;} public static class Name {private String firstName; private String lastName; public Name (String firstName, String lastName) {this.firstName = firstName This.lastName = lastName;} / / getter and setter} / / getter and setter}
Example 6
Import com.fasterxml.jackson.annotation.JsonSubTypes;import com.fasterxml.jackson.annotation.JsonTypeInfo;import com.fasterxml.jackson.annotation.JsonTypeName;public class Zoo {private Animal animal; public Zoo (Animal animal) {this.animal = animal } @ JsonTypeInfo (use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @ JsonSubTypes ({@ JsonSubTypes.Type (value = Dog.class, name = "dog"), @ JsonSubTypes.Type (value = Cat.class, name = "cat")} public static class Animal {private String name; public Animal (String name) {this.name = name } public String getName () {return name;} public void setName (String name) {this.name = name;}} @ JsonTypeName ("dog") public static class Dog extends Animal {private double barkVolume; public Dog (String name) {super (name) } public double getBarkVolume () {return barkVolume;} public void setBarkVolume (double barkVolume) {this.barkVolume = barkVolume;}} @ JsonTypeName ("cat") public static class Cat extends Animal {private boolean likesCream; private int lives; public Cat (String name) {super (name) } public boolean isLikesCream () {return likesCream;} public void setLikesCream (boolean likesCream) {this.likesCream = likesCream;} public int getLives () {return lives;} public void setLives (int lives) {this.lives = lives } public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new Zoo (new Dog ("lacy"); System.out.println (JsonUtil.generate (new Zoo (new Cat ("tom");} public Animal getAnimal () {return animal;} public void setAnimal (Animal animal) {this.animal = animal;}}
Output result:
{"animal": {"type": "dog", "name": "lacy", "barkVolume": 0.0}} {"animal": {"type": "cat", "name": "tom", "likesCream": false, "lives": 0}
Example 7
If the two-way association is not handled, an error occurs: com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError), which can be combined with @ JsonManagedReference and @ JsonBackReference.
Public class Hero {private Integer id; private String name; @ JsonManagedReference private List races = new ArrayList (); public static void main (String [] args) throws Exception {Hero hero = new Hero (1, "jason"); Race race = new Race (1, "marathon", 42.195f); hero.addRace (race); System.out.println (JsonUtil.generate (hero)); System.out.println (JsonUtil.generate (race)) } public Hero (Integer id, String name) {this.id = id; this.name = name;} public void addRace (Race race) {races.add (race); race.setHero (this);} / / getter and setter} import com.fasterxml.jackson.annotation.JsonBackReference;public class Race {private Integer id; private String type; private Float distance; @ JsonBackReference private Hero hero Public Race (Integer id, String type, Float distance) {this.id = id; this.type = type; this.distance = distance;} / / getter and setter}
Output result:
{"id": 1, "name": "jason", "races": [{"id": 1, "type": "marathon", "distance": 42.195}]} {"id": 1, "type": "marathon", "distance": 42.195}
Example 8
Another solution for two-way association uses @ JsonIdentityInfo.
Import com.fasterxml.jackson.annotation.JsonIdentityInfo;import com.fasterxml.jackson.annotation.ObjectIdGenerators;import java.util.ArrayList;import java.util.List;@JsonIdentityInfo (generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Hero {private Integer id; private String name; private List races = new ArrayList (); public static void main (String [] args) throws Exception {Hero hero = new Hero (1, "jason") Race race = new Race (1, "marathon", 42.195f); hero.addRace (race); System.out.println (JsonUtil.generate (hero)); System.out.println (JsonUtil.generate (race));} public Hero (Integer id, String name) {this.id = id; this.name = name;} public void addRace (Race race) {races.add (race) Race.setHero (this);} / / getter and setter} import com.fasterxml.jackson.annotation.JsonIdentityInfo;import com.fasterxml.jackson.annotation.ObjectIdGenerators;@JsonIdentityInfo (generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Race {private Integer id; private String type; private Float distance; private Hero hero; public Race (Integer id, String type, Float distance) {this.id = id; this.type = type This.distance = distance;} / / getter and setter}
Output result:
{"id": 1, "name": "jason", "races": [{"id": 1, "type": "marathon", "distance": 42.195, "hero": 1}]} {"id": 1, "type": "marathon", "distance": 42.195, "hero": {"id": 1, "name": "jason", "races": [1]}}
Example 9
In the above example, if the Race serialization result contains only hero id, you can use a combination of @ JsonIdentityInfo and @ JsonIdentityReference.
Import com.fasterxml.jackson.annotation.JsonIdentityInfo;import com.fasterxml.jackson.annotation.ObjectIdGenerators;import java.util.ArrayList;import java.util.List;@JsonIdentityInfo (generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", resolver = HeroIdResolver.class) public class Hero {private Integer id; private String name; private List races = new ArrayList (); public static void main (String [] args) throws Exception {Hero hero = new Hero (1, "jason") Race race = new Race (1, "marathon", 42.195f); hero.addRace (race); System.out.println (JsonUtil.generate (hero)); System.out.println (JsonUtil.generate (race));} public Hero (Integer id) {this.id = id;} public Hero (Integer id, String name) {this.id = id; this.name = name } public void addRace (Race race) {races.add (race); race.setHero (this);} / / getter and setter} import com.fasterxml.jackson.annotation.JsonIdentityInfo;import com.fasterxml.jackson.annotation.ObjectIdGenerators;@JsonIdentityInfo (generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Race {private Integer id; private String type; private Float distance; @ JsonIdentityReference (alwaysAsId = true) @ JsonProperty ("heroId") private Hero hero Public Race (Integer id, String type, Float distance) {this.id = id; this.type = type; this.distance = distance;} / / getter and setter}
To support deserialization, you need to customize ObjectIdResolver:
Import com.fasterxml.jackson.annotation.ObjectIdGenerator;import com.fasterxml.jackson.annotation.ObjectIdResolver;public class HeroIdResolver implements ObjectIdResolver {@ Override public void bindItem (ObjectIdGenerator.IdKey id, Object pojo) {} @ Override public Object resolveId (ObjectIdGenerator.IdKey id) {return new Hero ((Integer) id.key);} @ Override public ObjectIdResolver newForDeserialization (Object context) {return new HeroIdResolver () @ Override public boolean canUseFor (ObjectIdResolver resolverType) {return resolverType.getClass () = = getClass ();}}
Output result:
{"id": 1, "name": "jason", "races": [{"id": 1, "type": "marathon", "distance": 42.195, "heroId": 1}]} {"id": 1, "type": "marathon", "distance": 42.195, "heroId": 1}
Example 10
Customize Annotation to combine multiple Annotation.
Import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;import com.fasterxml.jackson.annotation.JsonInclude;import com.fasterxml.jackson.annotation.JsonPropertyOrder;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;@Retention (RetentionPolicy.RUNTIME) @ JacksonAnnotationsInside@JsonInclude (JsonInclude.Include.NON_NULL) @ JsonPropertyOrder ({"name", "id", "dateCreated") public @ interface CustomAnnotation {} import java.util.Date;@CustomAnnotationpublic class HeroWithCustomAnnotation {private Integer id; private String name; private Date dateCreated Public static void main (String [] args) throws Exception {System.out.println (JsonUtil.generate (new HeroWithCustomAnnotation (1, "Jason", null));} public HeroWithCustomAnnotation (Integer id, String name, Date dateCreated) {this.id = id; this.name = name; this.dateCreated = dateCreated;} / / getter and setter}
Output result:
{"name": "Jason", "id": 1} Spring Boot and Jackson
Spring Boot uses HttpMessageConverters to handle content transformations in HTTP exchanges. When Jackson exists in classpath, Jackson2ObjectMapperBuilder provides the default Converter. Please see HttpMessageConverters and WebMvcConfigurationSupport for source code:
HttpMessageConverters
Private List > converters = new ArrayList (); if (ClassUtils.isPresent ("org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport", null)) {converters.addAll (new WebMvcConfigurationSupport () {public List > messageConverters) {StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter (); stringHttpMessageConverter.setWriteAcceptCharset (false); / / see SPR-7316 messageConverters.add (new ByteArrayHttpMessageConverter ()); messageConverters.add (stringHttpMessageConverter); messageConverters.add (new ResourceHttpMessageConverter ()) MessageConverters.add (new ResourceRegionHttpMessageConverter ()); messageConverters.add (new SourceHttpMessageConverter ()); messageConverters.add (new AllEncompassingFormHttpMessageConverter ()); If (jackson2Present) {Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json (); if (this.applicationContext! = null) {builder.applicationContext (this.applicationContext);} messageConverters.add (new MappingJackson2HttpMessageConverter (builder.build ();}.}
Jackson2ObjectMapperBuilder creates an ObjectMapper instance:
Jackson2ObjectMapperBuilder
Public T build () {ObjectMapper mapper; if (this.createXmlMapper) {mapper = (this.defaultUseWrapper! = null? New XmlObjectMapperInitializer () .create (this.defaultUseWrapper): new XmlObjectMapperInitializer () .create ();} else {mapper = (this.factory! = null? New ObjectMapper (this.factory): new ObjectMapper ();} configure (mapper); return (T) mapper;}... private void customizeDefaultFeatures (ObjectMapper objectMapper) {if (! this.features.containsKey (MapperFeature.DEFAULT_VIEW_INCLUSION)) {configureFeature (objectMapper, MapperFeature.DEFAULT_VIEW_INCLUSION, false) } if (! this.features.containsKey (DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) {configureFeature (objectMapper, DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);}}
MapperFeature.DEFAULT_VIEW_INCLUSION and DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES are disabled by default.
WRITE_DATES_AS_TIMESTAMPS is disabled by default in Auto Configurationk:
JacksonAutoConfiguration
Static {Map featureDefaults = new HashMap (); featureDefaults.put (SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); FEATURE_DEFAULTS = Collections.unmodifiableMap (featureDefaults);} configure Jackson
The corresponding configurations are provided for all six Feature,Spring Boot for ObjectMapper. The list is as follows:
Feature (Enum) Spring Boot PropertyValuescom.fasterxml.jackson.databind.DeserializationFeaturespring.jackson.deserialization.feature_nametrue, falsecom.fasterxml.jackson.core.JsonGenerator.Featurespring.jackson.generator.feature_nametrue, falsecom.fasterxml.jackson.databind.MapperFeaturespring.jackson.mapper.feature_nametrue, falsecom.fasterxml.jackson.core.JsonParser.Featurespring.jackson.parser.feature_nametrue, falsecom.fasterxml.jackson.databind.SerializationFeaturespring.jackson.serialization.feature_nametrue, falsecom.fasterxml.jackson.annotation.JsonInclude.Includespring.jackson.default-property-inclusionalways, non_null, non_absent, non_default Non_empty
For example, to enable beautification printing, setting spring.jackson.serialization.indent_output=true is equivalent to enabling SerializationFeature.INDENT_OUTPUT, and feature_name case is ignored in the configuration.
Other Jackson configuration properties:
Spring.jackson.date-format= # Date format string or a fully-qualified date format class name. For instance, yyyy-MM-dd HH:mm:ss.spring.jackson.joda-date-time-format= # Joda date time format string. If not configured, "date-format" is used as a fallback if it is configured with a format string.spring.jackson.locale= # Locale used for formatting.spring.jackson.property-naming-strategy= # One of the constants on Jackson's PropertyNamingStrategy. Can also be a fully-qualified class name of a PropertyNamingStrategy subclass.spring.jackson.time-zone= # Time zone used when formatting dates. For instance, "America/Los_Angeles" or "GMT+10".
The default value of spring.jackson.date-format is com.fasterxml.jackson.databind.util.StdDateFormat.
@ DateTimeFormat and @ JsonFormat
In REST programming, when a POST/PUT request for application/json is submitted, JSON is converted through Jackson. When submitting a GET request, if the parameter contains a date, the backend code needs to use the annotation @ DateTimeFormat:
@ DateTimeFormat (pattern = "yyyy-MM-dd") private Date startDate
Both can be used simultaneously:
@ JsonFormat (shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") @ DateTimeFormat (pattern = "yyyy-MM-dd") private Date startDate;JSON code @ RestController@RequestMapping (value = "/ api", produces = MediaType.APPLICATION_JSON_VALUE) @ Api (tags = {"HelloController"}) public class HelloController {.}
JSON MediaType is "application/json;charset=UTF-8" and the default charset is "UTF-8".
If the legacy code uses GBK coding, will it take effect if we change the produces to "application/json;charset=GBK"? According to the JSON specification The JavaScript Object Notation (JSON) Data Interchange Format-Character Encoding,JSON only supports UTF-8, UTF-16, UTF-32 encoding.
Check the source code to verify:
AbstractJackson2HttpMessageConverter
Public abstract class AbstractJackson2HttpMessageConverter extends AbstractGenericHttpMessageConverter {@ Override protected void writeInternal (Object object, @ Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {MediaType contentType = outputMessage.getHeaders (). GetContentType (); JsonEncoding encoding = getJsonEncoding (contentType); JsonGenerator generator = this.objectMapper.getFactory (). CreateGenerator (outputMessage.getBody (), encoding);...}. Protected JsonEncoding getJsonEncoding (@ Nullable MediaType contentType) {if (contentType! = null & & contentType.getCharset ()! = null) {Charset charset = contentType.getCharset (); for (JsonEncoding encoding: JsonEncoding.values ()) {if (charset.name (). Equals (encoding.getJavaName () {return encoding } return JsonEncoding.UTF8;}}
JsonEncoding
Public enum JsonEncoding {UTF8 ("UTF-8", false, 8), / / N for big-endian A for big-endian, really UTF16_BE ("UTF-16BE", true, 16), UTF16_LE ("UTF-16LE", false, 16), UTF32_BE ("UTF-32BE", true, 32), UTF32_LE ("UTF-32LE", false, 32).}
You can see that JsonEncoding contains only UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, and UTF-32LE codes.
Reference documentation
Jackson Annotation Examples
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.