Interface Documentation:
App Configuration Interface client/init request data JSON={"UID": "", "Sid": "", "ver": "1", "Request": {}} returned data {"ret": 0, "Response":{ "Tag_category":{ Chinese painting:{ "Age": ["pre-Qin and Han dynasties", "The Warring states Chu", "Wei Jin North and South", "Sui and Tang Dynasties", "Southern Song Dynasty", "Yuan Dynasty", "Ming and Qing", "modern", "Age Unknown", "other"], "Technique": ["Splash", "meticulous", "freehand", "Baimiao", "sketch", "Texturing method", "No Bone", "finger painting", "other"], ... }, Calligraphy:{ "Classification": ["calligraphy", "rubbing from", "Writing scripture", "Letters clerical", "other"], "Chirography": ["Seal Script", "script", "Regular script", "cursive", "Running script", "other"], ... }, ... } }} Note tag_category label classification
First of all naturally think of encapsulation into JavaBean.
Note the point:
1, the internal nested class must be static, otherwise the parsing will be wrong;
2. The attribute name inside the class must be identical to the key in the JSON field;
3. Because the key in the JSON field exists in Chinese, you must use the @serializedname ("Chinese painting") annotation on the corresponding field to alias the key.
4, internal embedded {} is defined as public chinapicture chinapicture, the part enclosed in [] is a List, so it is defined as public list<string> years.
5. If you do not want to write the get and set methods, you only need to define the fields as public.
Public classJsonbean { Public intret; PublicResponse Response; Public Static classResponse { Publictagcategory tag_category; Public Static classtagcategory {@SerializedName (Chinese painting) Publicchinapicture chinapicture; /*** Chinese Painting*/ Public Static classchinapicture {@SerializedName (Age) PublicList<string>years; @SerializedName (Techniques) PublicList<string>techniques; @SerializedName (Theme) PublicList<string>topic; @SerializedName (Specifications) PublicList<string>specification; } @SerializedName (Calligraphy) Publiccalligraphy Calligraphy; /*** Calligraphy*/ Public Static classCalligraphy {@SerializedName (Classification) PublicList<string>classification; @SerializedName (Chirography) PublicList<string>chirography; @SerializedName (Specifications) PublicList<string>specification; } @SerializedName ("Western Painting") Publicwesternpicture westernpicture; /*** Western Painting*/ Public Static classwesternpicture {@SerializedName (Techniques) PublicList<string>techniques; @SerializedName (Theme) PublicList<string>topic; } @SerializedName (Stamps) Publicstamps Stamps; /*** Philatelic Products*/ Public Static classStamps {@SerializedName (Classification) PublicList<string>classification; @SerializedName (Specifications) PublicList<string>specification; } @SerializedName (Coins) PublicMoney Money ; /*** Coins*/ Public Static classMoney {@SerializedName (Classification) PublicList<string>classification; @SerializedName (Countries) PublicList<string>Country; @SerializedName (Specifications) PublicList<string>specification; } @SerializedName (Porcelain) PublicChina ; /*** Porcelain*/ Public Static classChina {@SerializedName (Age) PublicList<string>years; @SerializedName (Classification) PublicList<string>classification; } @SerializedName ("Purple clay Pot") Publicteapot teapot; /*** Purple Clay pot*/ Public Static classteapot {@SerializedName (Specifications) PublicList<string>specification; @SerializedName ("Mud Material") PublicList<string>Pug; @SerializedName (Process) PublicList<string>Crafts; @SerializedName (Industry) PublicList<string>industry; } @SerializedName ("Gold and silver Bronze") PublicMetaltool Metaltool; /*** Gold and silver bronze*/ Public Static classMetaltool {@SerializedName (Age) PublicList<string>years; @SerializedName (Classification) PublicList<string>classification; } @SerializedName ("Wood Furniture") Publicwoodfurniture woodfurniture; /*** Wood Furniture*/ Public Static classwoodfurniture {@SerializedName (Material) PublicList<string>material; @SerializedName ("Type of the device") PublicList<string>Shape; } @SerializedName ("Jade Jade") PublicEmerald Emerald; /*** Jade Jade*/ Public Static classEmerald {@SerializedName (Material) PublicList<string>material; @SerializedName (Mosaic) PublicList<string>inlay; @SerializedName (Classification) PublicList<string>classification; } @SerializedName ("Redwood Scholar's Objects") PublicRedwoodheritage Redwoodheritage; /*** Redwood Scholar's Objects*/ Public Static classredwoodheritage {@SerializedName (Classification) PublicList<string>classification; @SerializedName (Material) PublicList<string>material; } @SerializedName (Miscellaneous) PublicOtheritems Otheritems; /*** Miscellaneous*/ Public Static classOtheritems {@SerializedName (Age) PublicList<string>years; } } }}
Use Gson to parse complex, perverted JSON data