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.
There will be a prompt during installation, click Accept, wait for the installation to complete, and click OK to close the Setting interface.
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.
2. Right-click Generate and open GsonFormatPlus
3. The following JSON data view box appears.
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.
5. Put the data to be parsed into the input box on the left.
6. Click Format to format, and find that the data becomes very regular.
7. Click OK to start generating the entity class, displaying the name and type of the key.
8. Click OK again, and an entity class will be generated for you!
Online JSON verification and formatting tools can also help us format messy JSON data quickly and easily.