简体   繁体   中英

how ObjectMapper class methods works internally like readvalue() and writevalue()

ObjectMapper 类方法如何在内部工作,如 read value() 和 write value() 我的问题是我想在对象映射器的帮助下将 JSON 对象转换为 java 对象,但我想知道如何在内部读取值

student.json

{ "id": 1, "name": "Poornima", "age": 18, "standard": "XI", "address": { "street": "Main Street", "city": "Chelsea", "zipcode": 20571 }, "courses": [ "Science", "Physical Education" ] }

Take the example of preceding nested JSON object. It consist of JSON Object and a JSON Array within a JSON Object.Based on the JSON data, we'll create two POJOs: Courses and Students.

Internally When ObjectMapper maps JSON to POJOs, it inspects the setter methods. ObjectMapper by default maps a key for the JSON field with the setter method name. For Example, ObjectMapper will map the name JSON field with the setName() setter method in a POJO.

For more info you can refer following link https://dzone.com/articles/processing-json-with-jackson

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM