blob: a5cec6b7e2317c7661fcc0a635082247dabe6628 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>JsonParser (JSON Processing API documentation)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="JsonParser (JSON Processing API documentation)";
}
}
catch(err) {
}
//-->
var data = {"i0":6,"i1":18,"i2":18,"i3":6,"i4":6,"i5":6,"i6":6,"i7":18,"i8":18,"i9":6,"i10":18,"i11":18,"i12":6,"i13":6,"i14":6,"i15":18,"i16":18};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/JsonParser.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><br>JSON Processing API v2.0.0</div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="moduleLabelInType">Module</span>&nbsp;<a href="../../../module-summary.html">jakarta.json</a></div>
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">jakarta.json.stream</a></div>
<h2 title="Interface JsonParser" class="title">Interface JsonParser</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang" class="externalLink">AutoCloseable</a></code>, <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Closeable.html?is-external=true" title="class or interface in java.io" class="externalLink">Closeable</a></code></dd>
</dl>
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><code><a href="../../../org/glassfish/json/JsonParserImpl.html" title="class in org.glassfish.json">JsonParserImpl</a></code></dd>
</dl>
<hr>
<pre>public interface <span class="typeNameLabel">JsonParser</span>
extends <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Closeable.html?is-external=true" title="class or interface in java.io" class="externalLink">Closeable</a></pre>
<div class="block">Provides forward, read-only access to JSON data in a streaming way. This
is the most efficient way for reading JSON data.
This is the only way to parse and process JSON data that are too big to be loaded in memory.
<p>The class
<a href="../Json.html" title="class in jakarta.json"><code>Json</code></a> contains methods to create parsers from input
sources (<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/InputStream.html?is-external=true" title="class or interface in java.io" class="externalLink"><code>InputStream</code></a> and <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Reader.html?is-external=true" title="class or interface in java.io" class="externalLink"><code>Reader</code></a>).
<p>
The following example demonstrates how to create a parser from a string
that contains an empty JSON array:
<pre>
<code>
JsonParser parser = Json.createParser(new StringReader("[]"));
</code>
</pre>
<p>
The class <a href="JsonParserFactory.html" title="interface in jakarta.json.stream"><code>JsonParserFactory</code></a> also contains methods to create
<code>JsonParser</code> instances. <a href="JsonParserFactory.html" title="interface in jakarta.json.stream"><code>JsonParserFactory</code></a> is preferred
when creating multiple parser instances. A sample usage is shown
in the following example:
<pre>
<code>
JsonParserFactory factory = Json.createParserFactory();
JsonParser parser1 = factory.createParser(...);
JsonParser parser2 = factory.createParser(...);
</code>
</pre>
<p>
<code>JsonParser</code> parses JSON using the pull parsing programming model.
In this model the client code controls the thread and calls the method
<code>next()</code> to advance the parser to the next state after
processing each element. The parser can generate the following events:
<code>START_OBJECT</code>, <code>END_OBJECT</code>, <code>START_ARRAY</code>,
<code>END_ARRAY</code>, <code>KEY_NAME</code>, <code>VALUE_STRING</code>,
<code>VALUE_NUMBER</code>, <code>VALUE_TRUE</code>, <code>VALUE_FALSE</code>,
and <code>VALUE_NULL</code>.
<p>
<b>For example</b>, for an empty JSON object ({ }), the parser generates the event
<code>START_OBJECT</code> with the first call to the method <code>next()</code> and the
event <code>END_OBJECT</code> with the second call to the method <code>next()</code>.
The following code demonstrates how to access these events:
<pre>
<code>
Event event = parser.next(); // START_OBJECT
event = parser.next(); // END_OBJECT
</code>
</pre>
<p>
<b>For example</b>, for the following JSON:
<pre>
{
"firstName": "John", "lastName": "Smith", "age": 25,
"phoneNumber": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}
</pre>
<p>calls to the method <code>next()</code> result in parse events at the specified
locations below (marked in bold):
<pre>
{<B>START_OBJECT</B>
"firstName"<B>KEY_NAME</B>: "John"<B>VALUE_STRING</B>, "lastName"<B>KEY_NAME</B>: "Smith"<B>VALUE_STRING</B>, "age"<B>KEY_NAME</B>: 25<B>VALUE_NUMBER</B>,
"phoneNumber"<B>KEY_NAME</B> : [<B>START_ARRAY</B>
{<B>START_OBJECT</B> "type"<B>KEY_NAME</B>: "home"<B>VALUE_STRING</B>, "number"<B>KEY_NAME</B>: "212 555-1234"<B>VALUE_STRING</B> }<B>END_OBJECT</B>,
{<B>START_OBJECT</B> "type"<B>KEY_NAME</B>: "fax"<B>VALUE_STRING</B>, "number"<B>KEY_NAME</B>: "646 555-4567"<B>VALUE_STRING</B> }<B>END_OBJECT</B>
]<B>END_ARRAY</B>
}<B>END_OBJECT</B>
</pre>
The methods <a href="#next()"><code>next()</code></a> and <a href="#hasNext()"><code>hasNext()</code></a> enable iteration over
parser events to process JSON data. <code>JsonParser</code> provides get methods
to obtain the value at the current state of the parser. For example, the
following code shows how to obtain the value "John" from the JSON above:
<pre>
<code>
Event event = parser.next(); // START_OBJECT
event = parser.next(); // KEY_NAME
event = parser.next(); // VALUE_STRING
parser.getString(); // "John"
</code>
</pre>
Starting in version 1.1, it is possible to build a partial JSON object
model from the stream, at the current parser position.
The methods <a href="#getArray()"><code>getArray()</code></a> and <a href="#getObject()"><code>getObject()</code></a> can be used to read in
a <code>JsonArray</code> or <code>JsonObject</code>. For example, the following code
shows how to obtain the phoneNumber in a JsonArray, from the JSON above:
<pre><code>
while (parser.hasNext() {
Event event = parser.next();
if (event == JsonParser.Event.KEY_NAME ) {
String key = getString();
event = parser.next();
if (key.equals("phoneNumber") {
JsonArray phones = parser.getArray();
}
}
}
</code></pre>
The methods <a href="#getArrayStream()"><code>getArrayStream()</code></a> and <a href="#getObjectStream()"><code>getObjectStream()</code></a> can be used
to get a stream of the elements of a <code>JsonArray</code> or <code>JsonObject</code>.
For example, the following code shows another way to obtain John's phoneNumber
in a <code>JsonArray</code> :
<pre><code>
Event event = parser.next(); // START_OBJECT
JsonArray phones = (JsonArray)
parser.getObjectStream().filter(e-&gt;e.getKey().equals("phoneNumber"))
.map(e-&gt;e.getValue())
.findFirst()
.get();
</code></pre>
The methods <a href="#skipArray()"><code>skipArray()</code></a> and <a href="#skipObject()"><code>skipObject()</code></a> can be used to
skip tokens and position the parser to <code>END_ARRAY</code> or
<code>END_OBJECT</code>.
<p>
<code>JsonParser</code> can be used to parse sequence of JSON values that are not
enclosed in a JSON array, e.g. { } { }. The following code demonstrates how
to parse such sequence.
<pre><code>
JsonParser parser = Json.createParser(...);
while (parser.hasNext) {
parser.next(); // advance parser state
JsonValue value = parser.getValue();
}
</code></pre></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../Json.html" title="class in jakarta.json"><code>Json</code></a>,
<a href="JsonParserFactory.html" title="interface in jakarta.json.stream"><code>JsonParserFactory</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="JsonParser.Event.html" title="enum in jakarta.json.stream">JsonParser.Event</a></span></code></th>
<td class="colLast">
<div class="block">An event from <code>JsonParser</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t5" class="tableTab"><span><a href="javascript:show(16);">Default Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#close()">close</a></span>()</code></th>
<td class="colLast">
<div class="block">Closes this parser and frees any resources associated with the
parser.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>default <a href="../JsonArray.html" title="interface in jakarta.json">JsonArray</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getArray()">getArray</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a <code>JsonArray</code> and advance the parser to the
the corresponding <code>END_ARRAY</code>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>default <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getArrayStream()">getArrayStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a stream of the <code>JsonArray</code> elements.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math" class="externalLink">BigDecimal</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getBigDecimal()">getBigDecimal</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a JSON number as a <code>BigDecimal</code>.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getInt()">getInt</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a JSON number as an integer.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="JsonLocation.html" title="interface in jakarta.json.stream">JsonLocation</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getLocation()">getLocation</a></span>()</code></th>
<td class="colLast">
<div class="block">Return the location that corresponds to the parser's current state in
the JSON input source.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>long</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getLong()">getLong</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a JSON number as a long.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>default <a href="../JsonObject.html" title="interface in jakarta.json">JsonObject</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getObject()">getObject</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a <code>JsonObject</code> and advances the parser to the
corresponding <code>END_OBJECT</code>.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>default <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.Entry.html?is-external=true" title="class or interface in java.util" class="externalLink">Map.Entry</a>&lt;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>,&#8203;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getObjectStream()">getObjectStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a stream of the <code>JsonObject</code>'s
name/value pairs.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getString()">getString</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a <code>String</code> for the name in a name/value pair,
for a string value or a number value.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>default <a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getValue()">getValue</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a <code>JsonValue</code> at the current parser position.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>default <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getValueStream()">getValueStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a stream of <code>JsonValue</code> from a sequence of
JSON values.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hasNext()">hasNext</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns <code>true</code> if there are more parsing states.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isIntegralNumber()">isIntegralNumber</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns true if the JSON number at the current parser state is a
integral number.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code><a href="JsonParser.Event.html" title="enum in jakarta.json.stream">JsonParser.Event</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#next()">next</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the event for the next parsing state.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>default void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#skipArray()">skipArray</a></span>()</code></th>
<td class="colLast">
<div class="block">Advance the parser to <code>END_ARRAY</code>.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>default void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#skipObject()">skipObject</a></span>()</code></th>
<td class="colLast">
<div class="block">Advance the parser to <code>END_OBJECT</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="hasNext()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hasNext</h4>
<pre class="methodSignature">boolean&nbsp;hasNext()</pre>
<div class="block">Returns <code>true</code> if there are more parsing states. This method returns
<code>false</code> if the parser reaches the end of the JSON text.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if there are more parsing states.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../JsonException.html" title="class in jakarta.json">JsonException</a></code> - if an i/o error occurs (IOException
would be cause of JsonException)</dd>
<dd><code><a href="JsonParsingException.html" title="class in jakarta.json.stream">JsonParsingException</a></code> - if the parser encounters invalid JSON
when advancing to next state.</dd>
</dl>
</li>
</ul>
<a id="next()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>next</h4>
<pre class="methodSignature"><a href="JsonParser.Event.html" title="enum in jakarta.json.stream">JsonParser.Event</a>&nbsp;next()</pre>
<div class="block">Returns the event for the next parsing state.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the event for the next parsing state</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../JsonException.html" title="class in jakarta.json">JsonException</a></code> - if an i/o error occurs (IOException
would be cause of JsonException)</dd>
<dd><code><a href="JsonParsingException.html" title="class in jakarta.json.stream">JsonParsingException</a></code> - if the parser encounters invalid JSON
when advancing to next state.</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/NoSuchElementException.html?is-external=true" title="class or interface in java.util" class="externalLink">NoSuchElementException</a></code> - if there are no more parsing
states.</dd>
</dl>
</li>
</ul>
<a id="getString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getString</h4>
<pre class="methodSignature"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;getString()</pre>
<div class="block">Returns a <code>String</code> for the name in a name/value pair,
for a string value or a number value. This method should only be called
when the parser state is <a href="JsonParser.Event.html#KEY_NAME"><code>JsonParser.Event.KEY_NAME</code></a>, <a href="JsonParser.Event.html#VALUE_STRING"><code>JsonParser.Event.VALUE_STRING</code></a>,
or <a href="JsonParser.Event.html#VALUE_NUMBER"><code>JsonParser.Event.VALUE_NUMBER</code></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a name when the parser state is <a href="JsonParser.Event.html#KEY_NAME"><code>JsonParser.Event.KEY_NAME</code></a>
a string value when the parser state is <a href="JsonParser.Event.html#VALUE_STRING"><code>JsonParser.Event.VALUE_STRING</code></a>
a number value when the parser state is <a href="JsonParser.Event.html#VALUE_NUMBER"><code>JsonParser.Event.VALUE_NUMBER</code></a></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>KEY_NAME</code>, <code>VALUE_STRING</code>, or <code>VALUE_NUMBER</code></dd>
</dl>
</li>
</ul>
<a id="isIntegralNumber()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isIntegralNumber</h4>
<pre class="methodSignature">boolean&nbsp;isIntegralNumber()</pre>
<div class="block">Returns true if the JSON number at the current parser state is a
integral number. A <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math" class="externalLink"><code>BigDecimal</code></a> may be used to store the value
internally and this method semantics are defined using its
<code>scale()</code>. If the scale is zero, then it is considered integral
type. This integral type information can be used to invoke an
appropriate accessor method to obtain a numeric value as in the
following example:
<pre>
<code>
JsonParser parser = ...
if (parser.isIntegralNumber()) {
parser.getInt(); // or other methods to get integral value
} else {
parser.getBigDecimal();
}
</code>
</pre></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this number is a integral number, otherwise false</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>VALUE_NUMBER</code></dd>
</dl>
</li>
</ul>
<a id="getInt()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInt</h4>
<pre class="methodSignature">int&nbsp;getInt()</pre>
<div class="block">Returns a JSON number as an integer. The returned value is equal
to <code>new BigDecimal(getString()).intValue()</code>. Note that
this conversion can lose information about the overall magnitude
and precision of the number value as well as return a result with
the opposite sign. This method should only be called when the parser
state is <a href="JsonParser.Event.html#VALUE_NUMBER"><code>JsonParser.Event.VALUE_NUMBER</code></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an integer for a JSON number</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>VALUE_NUMBER</code></dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html?is-external=true#intValue()" title="class or interface in java.math" class="externalLink"><code>BigDecimal.intValue()</code></a></dd>
</dl>
</li>
</ul>
<a id="getLong()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLong</h4>
<pre class="methodSignature">long&nbsp;getLong()</pre>
<div class="block">Returns a JSON number as a long. The returned value is equal
to <code>new BigDecimal(getString()).longValue()</code>. Note that this
conversion can lose information about the overall magnitude and
precision of the number value as well as return a result with
the opposite sign. This method is only called when the parser state is
<a href="JsonParser.Event.html#VALUE_NUMBER"><code>JsonParser.Event.VALUE_NUMBER</code></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a long for a JSON number</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>VALUE_NUMBER</code></dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html?is-external=true#longValue()" title="class or interface in java.math" class="externalLink"><code>BigDecimal.longValue()</code></a></dd>
</dl>
</li>
</ul>
<a id="getBigDecimal()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBigDecimal</h4>
<pre class="methodSignature"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math" class="externalLink">BigDecimal</a>&nbsp;getBigDecimal()</pre>
<div class="block">Returns a JSON number as a <code>BigDecimal</code>. The <code>BigDecimal</code>
is created using <code>new BigDecimal(getString())</code>. This
method should only called when the parser state is
<a href="JsonParser.Event.html#VALUE_NUMBER"><code>JsonParser.Event.VALUE_NUMBER</code></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a <code>BigDecimal</code> for a JSON number</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>VALUE_NUMBER</code></dd>
</dl>
</li>
</ul>
<a id="getLocation()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLocation</h4>
<pre class="methodSignature"><a href="JsonLocation.html" title="interface in jakarta.json.stream">JsonLocation</a>&nbsp;getLocation()</pre>
<div class="block">Return the location that corresponds to the parser's current state in
the JSON input source. The location information is only valid in the
current parser state (or until the parser is advanced to a next state).</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a non-null location corresponding to the current parser state
in JSON input source</dd>
</dl>
</li>
</ul>
<a id="getObject()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getObject</h4>
<pre class="methodSignature">default&nbsp;<a href="../JsonObject.html" title="interface in jakarta.json">JsonObject</a>&nbsp;getObject()</pre>
<div class="block">Returns a <code>JsonObject</code> and advances the parser to the
corresponding <code>END_OBJECT</code>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>JsonObject</code> at the current parser position</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>START_OBJECT</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="getValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValue</h4>
<pre class="methodSignature">default&nbsp;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&nbsp;getValue()</pre>
<div class="block">Returns a <code>JsonValue</code> at the current parser position.
If the parser state is <code>START_ARRAY</code>, the behavior is
the same as <a href="#getArray()"><code>getArray()</code></a>. If the parser state is
<code>START_OBJECT</code>, the behavior is the same as
<a href="#getObject()"><code>getObject()</code></a>. For all other cases, if applicable, the JSON value is
read and returned.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>JsonValue</code> at the current parser position.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is
<code>END_OBJECT</code> or <code>END_ARRAY</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="getArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getArray</h4>
<pre class="methodSignature">default&nbsp;<a href="../JsonArray.html" title="interface in jakarta.json">JsonArray</a>&nbsp;getArray()</pre>
<div class="block">Returns a <code>JsonArray</code> and advance the parser to the
the corresponding <code>END_ARRAY</code>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>JsonArray</code> at the current parser position</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>START_ARRAY</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="getArrayStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getArrayStream</h4>
<pre class="methodSignature">default&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&nbsp;getArrayStream()</pre>
<div class="block">Returns a stream of the <code>JsonArray</code> elements.
The parser state must be <code>START_ARRAY</code>.
The elements are read lazily, on an as-needed basis, as
required by the stream operations.
If the stream operations do not consume
all of the array elements, <a href="#skipArray()"><code>skipArray()</code></a> can be used to
skip the unprocessed array elements.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a stream of elements of the <code>JsonArray</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>START_ARRAY</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="getObjectStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getObjectStream</h4>
<pre class="methodSignature">default&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.Entry.html?is-external=true" title="class or interface in java.util" class="externalLink">Map.Entry</a>&lt;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>,&#8203;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&gt;&nbsp;getObjectStream()</pre>
<div class="block">Returns a stream of the <code>JsonObject</code>'s
name/value pairs. The parser state must be <code>START_OBJECT</code>.
The name/value pairs are read lazily, on an as-needed basis, as
required by the stream operations.
If the stream operations do not consume
all of the object's name/value pairs, <a href="#skipObject()"><code>skipObject()</code></a> can be
used to skip the unprocessed elements.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a stream of name/value pairs of the <code>JsonObject</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - when the parser state is not
<code>START_OBJECT</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="getValueStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValueStream</h4>
<pre class="methodSignature">default&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Stream.html?is-external=true" title="class or interface in java.util.stream" class="externalLink">Stream</a>&lt;<a href="../JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&nbsp;getValueStream()</pre>
<div class="block">Returns a stream of <code>JsonValue</code> from a sequence of
JSON values. The values are read lazily, on an as-needed basis,
as needed by the stream operations.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Stream of <code>JsonValue</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang" class="externalLink">IllegalStateException</a></code> - if the parser is in an array or object.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="skipArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>skipArray</h4>
<pre class="methodSignature">default&nbsp;void&nbsp;skipArray()</pre>
<div class="block">Advance the parser to <code>END_ARRAY</code>.
If the parser is in array context, i.e. it has previously
encountered a <code>START_ARRAY</code> without encountering the
corresponding <code>END_ARRAY</code>, the parser is advanced to
the corresponding <code>END_ARRAY</code>.
If the parser is not in any array context, nothing happens.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="skipObject()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>skipObject</h4>
<pre class="methodSignature">default&nbsp;void&nbsp;skipObject()</pre>
<div class="block">Advance the parser to <code>END_OBJECT</code>.
If the parser is in object context, i.e. it has previously
encountered a <code>START_OBJECT</code> without encountering the
corresponding <code>END_OBJECT</code>, the parser is advanced to
the corresponding <code>END_OBJECT</code>.
If the parser is not in any object context, nothing happens.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a id="close()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>close</h4>
<pre class="methodSignature">void&nbsp;close()</pre>
<div class="block">Closes this parser and frees any resources associated with the
parser. This method closes the underlying input source.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/AutoCloseable.html?is-external=true#close()" title="class or interface in java.lang" class="externalLink">close</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang" class="externalLink">AutoCloseable</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Closeable.html?is-external=true#close()" title="class or interface in java.io" class="externalLink">close</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Closeable.html?is-external=true" title="class or interface in java.io" class="externalLink">Closeable</a></code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../JsonException.html" title="class in jakarta.json">JsonException</a></code> - if an i/o error occurs (IOException
would be cause of JsonException)</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/JsonParser.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><br>JSON Processing API v2.0.0</div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Comments to: <a href="mailto:jsonp-dev@eclipse.org">jsonp-dev@eclipse.org</a>.<br> Copyright &#169; 2019, 2020 Eclipse Foundation. All rights reserved.<br> Use is subject to <a href="../../../../doc-files/speclicense.html" target="_top">license terms</a>.</small></p>
</footer>
</body>
</html>