Jackson is a set of data processing library tools for the Java platform, and Jackson's main function is to provide JSON parsing and generation, and Jackson also provides additional class libraries to support the processing of Avro, CBOR, CSV, Smile, XML, and YAML, It's very powerful and it's great to work with JSON data in Java.
The relevant sample code:
{ "name" :{"First": "Joe", "Last": "Sixpack" } , "Gender" :"MALE", "verified" :false, "Userimage" : "rm9vymfyiq=="}
Public class User { Public enumGender {MALE, FEMALE}; Public Static class Name { PrivateString _first, _last; PublicString GetFirst () {return_first; } PublicString GetLast () {return_last; } Public voidSetfirst (String s) {_first = s;} Public voidSetlast (String s) {_last = s;} } PrivateGender _gender; PrivateName _name; Private Boolean_isverified; Private byte[] _userimage; PublicName GetName () {return_name; } Public BooleanIsverified () {return_isverified; } PublicGender Getgender () {return_gender; } Public byte[] Getuserimage () {return_userimage; } Public voidSetName (Name n) {_name = n;} Public voidSetverified (Booleanb) {_isverified = b;} Public voidSetgender (Gender g) {_gender = g;} Public voidSetuserimage (byte[] b) {_userimage = b;}}
New //Can reuse, share globally User user = Mapper.readvalue (new File ("User.json"), user. Class);
As a JSON-processing class library tool, Jackson is also very convenient to use.
Java JSON processing class library Jackson