Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Java EE 7 Development with NetBeans 8

You're reading from   Java EE 7 Development with NetBeans 8 Develop professional enterprise Java EE applications quickly and easily with this popular IDE

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher Packt
ISBN-13 9781783983520
Length 364 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
David R Heffelfinger David R Heffelfinger
Author Profile Icon David R Heffelfinger
David R Heffelfinger
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with NetBeans 2. Developing Web Applications Using JavaServer Faces 2.2 FREE CHAPTER 3. JSF Component Libraries 4. Interacting with Databases through the Java Persistence API 5. Implementing the Business Tier with Session Beans 6. Contexts and Dependency Injection 7. Messaging with JMS and Message-driven Beans 8. Java API for JSON Processing 9. Java API for WebSocket 10. RESTful Web Services with JAX-RS 11. SOAP Web Services with JAX-WS Index

The JSON-P object model API


The JSON-P model API allows us to generate an in-memory tree structured representation of a JSON object. The JSON-P API uses the builder pattern, which allows us as application developers to easily create a JSON representation of a Java object.

Generating JSON data with the JSON-P object model API

When using the JSON-P object model API, we typically start by invoking the add() method of an implementation of the JsonObjectBuilder interface. This method returns an instance of another JsonObjectBuilder interface implementation. We can chain invocations of JsonObject.add() together, allowing us to easily create a JSON representation from a Java object. The following example illustrates this process:

package com.ensode.jsonpmodelapi;

//imports omitted

@Named
@RequestScoped
public class JsonPModelApiBean {

    @Inject
    private Person person;
    private String jsonStr;

    public String generateJson() {
        JsonObjectBuilder jsonObjectBuilder =
            Json...
lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Java EE 7 Development with NetBeans 8
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime
Modal Close icon
Modal Close icon