Installation and use of GsonFormat in Android

Install

The GsonFormat plugin installation is very simple: File—>Settings—>Plugins, and then search for GSON. At present, GSONFormat has been upgraded to GsonFormatPlus, so select it to install.

insert image description here
There will be a prompt during installation, click Accept, wait for the installation to complete, and click OK to close the Setting interface.
insert image description here
In the project where you need to use GSON, open build.gradle(app), add the following dependencies in dependencies, and then synchronize. This completes all configuration.

implementation 'com.google.code.gson:gson:2.2.4'
use

1. Create a new PersonBean class.
insert image description here
2. Right-click Generate and open GsonFormatPlus

insert image description here
insert image description here
3. The following JSON data view box appears.
insert image description here
4. Don't rush to format the generation first, because Plus has many changes, and the generated data format is very different from the data format we want, so click Setting in the lower left corner, and then check it as shown below.

insert image description here
5. Put the data to be parsed into the input box on the left.
insert image description here
6. Click Format to format, and find that the data becomes very regular.
insert image description here
7. Click OK to start generating the entity class, displaying the name and type of the key.
insert image description here
8. Click OK again, and an entity class will be generated for you!

insert image description here
Online JSON verification and formatting tools can also help us format messy JSON data quickly and easily.
insert image description here

Guess you like

Origin blog.csdn.net/qq_42257666/article/details/123078304