Java JSON processing class library Jackson

Source: Internet
Author: User

Java JSON processing class library Jackson

Jackson is a set of data processing class libraries provided for the Java platform. Jackson's main function is to provide JSON parsing and generation. In addition, Jackson also provides additional class libraries to support Avro, CBOR, CSV, Smile, XML, and YAML have powerful functions and are very good at processing JSON data in Java.

Related sample code:

{  "name" : { "first" : "Joe", "last" : "Sixpack" },  "gender" : "MALE",  "verified" : false,  "userImage" : "Rm9vYmFyIQ=="}
public class User {  public enum Gender { MALE, FEMALE };  public static class Name {    private String _first, _last;    public String getFirst() { return _first; }    public String getLast() { return _last; }    public void setFirst(String s) { _first = s; }    public void setLast(String s) { _last = s; }  }  private Gender _gender;  private Name _name;  private boolean _isVerified;  private byte[] _userImage;  public Name getName() { return _name; }  public boolean isVerified() { return _isVerified; }  public Gender getGender() { return _gender; }  public byte[] getUserImage() { return _userImage; }  public void setName(Name n) { _name = n; }  public void setVerified(boolean b) { _isVerified = b; }  public void setGender(Gender g) { _gender = g; }  public void setUserImage(byte[] b) { _userImage = b; }}
ObjectMapper mapper = new ObjectMapper(); // can reuse, share globallyUser user = mapper.readValue(new File("user.json"), User.class);

Jackson, as a JSON processing class library tool, is also very convenient to use.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.