There is a json object that needs to be used a lot, so I want to encapsulate it into an object,
{tooltip : {
trigger: 'axis',
axisPointer: {type: 'cross',},
formatter: "{b}: {c})"},
xAxis :{
type : 'category',
data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {alignWithLabel: true}},
yAxis :{
type : 'value'},
series :{
type:'bar',
barWidth: '80%',
data:[10, 52, 200, 334, 390, 330, 220]}}
The current idea is to put one layer of objects and another layer of tooltip, xAxis, and series objects, but it is completely off target. It is just an auxiliary object. Are there any good practices?
Although I don’t quite understand your problem, it is a bit annoying to write some classes for json to represent the structure of this json... But there is an artifact that can help you solve this problem simply, haha
There is an artifact in IDEA called GsonFormat
This plug-in is very easy to use for processing json. No matter how complex the json is, as long as the json format is correct, it will automatically generate classes for you, haha
General usage steps are as follows:
Create a new class, for example, called Test. This class will be the last class you want to use
Then Alt+s to open the GsonFormat shortcut key
Paste the json string you want to convert and click ok
4. Confirm the format and type after conversion. Basically, the default is OK. Just click OK
Class generation:
Output: