Home > Back-end >  According to the style of Json generated the corresponding Java objects
According to the style of Json generated the corresponding Java objects

Time:11-10

Define a json style, field format is as follows:
{
"CId" : "Integer,"
"AId" : "String",
"StartTime", "Long",
"Config" : {
"PicType" : "Integer,"
"PicUrl" : "String",
"ShowField" : [
"Integer,"
"Integer"
],
"NeedRegister" : false
},
"Does" : "Boolean"
}

According to the field type to generate corresponding Java objects
Public class Test {
Private Integer cId.
Private String aId;
Private Long startTime.
Private Config Config.
Private Boolean does;

Getter/setter () ()
}

Public class Config {
Private picType picType;
Private String picUrl;
Private List ShowField;
Private Boolean needRegister;

Getter/setter () ()
}



Please tell the great god, thanked here

CodePudding user response:

You are going to use ready-made libraries or intend to parse the json?
If use merchant class library to download a few json packages, such as Jackson, org. Json packages, these packages have turn json object method,
If you want to write their own, with regular and reflection can handle, (to build their own wheels. There is no need)

CodePudding user response:

Import the jar package, com. Alibaba. Fastjson. JSONObject
Test obj=JSONObject. ParseObject (json, the Test class);

CodePudding user response:

You want to ask what? You write this is right
  • Related