Join Ketkee Aryamane for an in-depth discussion in this video Test custom constructors, part of Java EE 8: JSON-B.
- [Instructor] So now let's go ahead and test the scenario.…Let's make a class under the tests folder.…Let's call it TestCustomCreator.…Let's grab the main method, psvm.…Let's create an empty Jsonb instance.….create…So once you get that instance, what you're going to do is,…if you observe, this is our project folder,…and we have saved the order details file.…
So this is a JSON document.…Now, we're going to read this JSON representation…and then employ the custom creator for that.…Okay.…So let's go to the code.…Let's say jsonb.fromjson…And we'll employ the file reader to read that file,…which will demand a file object.…So we'll do that.…And it'll also demand the path of the object,…so that will be orderdetails.txt…And, of course, the type will be OrderDetails this time.…
OrderDetails.class…That's what we have to mention.…Okay.…And what we'll also do is we'll take the output of this…inside an OrderDetails object.…That's what we have to check, correct?…So ...…Okay.…Now, since we are reading the file,…of course it's going to throw the checked exception.…
- 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.