GSON and jsongson for JSON Conversion
During daily coding, you must record the simple usage of GSON when converting json data:
First, introduce the JAR package of Gson,
With the jar package, you can safely use it.
Gson can be used to convert many things, including list, map, set, and an object. However, gson must be used to convert data in some formats,
For example, if the date format is incorrect, record the gson conversion date format in detail.
My User object has a date-format birth. When converting the User list set, if not processed, the json is directly converted, as shown below:
This is the json data format obtained without processing:
Obviously this is not what we want, so what should we do? See the following:
The displayed result is. You only need to modify the parameters in setDateFormat ("yyyy-MM-dd") to achieve the desired effect.
Well, this is now.