Jackson JSON goto List

Source: Internet
Author: User

Today the project used Jackson, the manager said that more efficient, so began to use, the beginning of the JSON to the object, the object to JSON is still very simple, but there are still some problems, and then add a bit of configuration properties there is no error

1 New Objectmapper (); 2         Entity result = Mapper.readvalue (data, entity.  Class); 3         Entity result = Mapper.readvalue (data, entity.  Class);

If the object goes to JSON, the corresponding method is

        New Objectmapper ();           =  mapper.writevalueasstring (student1);    

But if the JSON into a list or array will become not so simple, from the Internet to find a lot of examples to try can not, later I brainwave, think of a way, that is to create the entity, and then directly to the object, found that really works, so it is here to record, for forgetting, The JSON string is as follows:

{"    data": {        "totalsize": 0,        "results": [],        "Empty": true    },    "Error_message": "",    "error _code ": 0,    " status ":" Success "}

The code for the turn is shown below

                New Objectmapper ();         = Mapper.readvalue (data, Repaymentresult.  Class);     

Found with the above-mentioned code, but this will create more than a few entity classes, but there is no turning the trouble, but one thing to remember, that is, the property value of the image and JSON inside the key value of the same can be Oh!

Jackson JSON goto List

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.