Skip to Content
RESTful Java Web Services - Third Edition
book

RESTful Java Web Services - Third Edition

by Balachandar Bogunuva Mohanram
November 2017
Intermediate to advanced
420 pages
10h 29m
English
Packt Publishing
Content preview from RESTful Java Web Services - Third Edition

Using streaming APIs to parse JSON data

In this section, you will learn the use of streaming APIs for converting JSON data into appropriate Java classes.

This example illustrates the use of streaming APIs for converting a JSON array of the employee objects present in the emp-array.json file into an appropriate Java class representation.

The following code snippet illustrates how you can use javax.json.stream.JsonParser, which follows the streaming parsing model, to read the content from the emp-array.json file:

  1. The first step is to get the input stream for reading the emp-array.json file. Then, you can create a JsonParser instance with the input stream, as follows:
//Other imports are removed for brevity import javax.json.stream.JsonParser; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java Web Services, Second Edition

RESTful Java Web Services, Second Edition

Jobinesh Purushothaman
Java Web Services

Java Web Services

David A Chappell, Tyler Jewell

Publisher Resources

ISBN: 9781788294041Supplemental Content