Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly convert JSON to objects in Idea plug-ins

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

How to quickly JSON objects in the Idea plug-in, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.

In development, there is often a scenario in which an JSON example is given and then defined as an object class to co-debug and test with the front end. If the Json is very long, a lot of time will be wasted on writing object classes.

Next, we recommend a plug-in for Idea: GsonFormatPlus (secondary development based on GsonFormat).

Installation

Search for GsonFormatPlus installation directly in Plugins-> Marketplace of Idea:

GsonFormatPlus

After installation, you need to restart Idea to take effect.

If the installation fails from Marketplace, you can download the plug-in's zip package and install it from disk.

Use

Here is a Json to test:

{"name": "Wang Wu", "gender": "man", "age": 15, "height": "140cm", "addr": {"province": "fujian", "city": "quanzhou", "code": "300000"} "hobby": [{"name": "billiards", "code": "1"}, {"name": "computerGame", "code": "2"}]}

In Idea, click Code-> Generate-> GsonFormatPlus:

You can also directly use the shortcut key Alt+S to generate it. The interface is as follows:

Type JSON on the left, and then you can set it in Setting according to your needs:

For example, whether to use Lombok, whether to use comments, field modifier selection, etc., you can try it yourself.

Click OK to generate, and you can also fill in the comments of the field when you generate it. The default comment information is the field name.

Click OK to generate the corresponding class:

Is it very simple? If you need it, you can try to download the plug-in yourself, which can improve the coding efficiency.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report