- [Instructor] Let's look at the second option…of customized mapping, which helps us…to change the bean attribute names.…Now, by default, we know that JSON Binding API…is going to pick up the names of the instance variables…as keys in the resulting JSON document.…Let's come back to the IDE and let's say,…open the customer class.…So whenever JSON-B is going to serialize…an object of this kind,…then the keys in the JSON document will be…customerid, customerName, emailAddress and isPrimeUser.…
However, there's an option with us…to change this default behavior,…and that is done using the @JSONbProperty annotation.…You can apply this either on the field name…or on the getter/setter, one of them.…And let's see how it behaves in both the cases.…Let's go back to the IDE.…And let's say that these two fields is something…that we want to change the names for.…So, I'm going to go on line 14 and say JSONbProperty.…And, I'm going to set the value of this to just id.…
I don't want CustomerId coming out in the JSON document,…I just want id.…
- JSON and JSON-B API basics
- Default mapping
- Defining beans and data
- Customized mapping
- Customizing the order of serialized properties
- Customizing constructors
- Working with binary data
- Custom serializers and deserializers
- Demo: Using JSON-B in a web application
Skill Level Intermediate
Java EE: RESTful Service with JAX-RS 2.0with Alex Theedom2h 17m Intermediate
Java EE: Servlets and JavaServer Pages (JSP)with Ketkee Aryamane6h 14m Intermediate
Map Java objects to JSON1m 14s
1. Overview and Setup
2. JSON Binding API: Default Mapping
3. JSON Binding API: Customized Mapping, Part 1
4. JSON Binding API: Customized Mapping, Part 2
5. Adapters and Serializers
6. JSON-B in a Web Application
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.