mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
2197 lines
94 KiB
HTML
2197 lines
94 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!-- NewPage -->
|
|
<html lang="de">
|
|
<head>
|
|
<!-- Generated by javadoc (1.8.0_05) on Sun Feb 14 02:15:50 CET 2016 -->
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>JSONObject (JSON in Java 20160212 API)</title>
|
|
<meta name="date" content="2016-02-14">
|
|
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
|
|
<script type="text/javascript" src="../../script.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
try {
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="JSONObject (JSON in Java 20160212 API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
var methods = {"i0":10,"i1":10,"i2":9,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":9,"i14":9,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":9,"i24":10,"i25":10,"i26":10,"i27":10,"i28":10,"i29":10,"i30":10,"i31":10,"i32":10,"i33":10,"i34":10,"i35":10,"i36":10,"i37":10,"i38":10,"i39":10,"i40":10,"i41":10,"i42":10,"i43":10,"i44":10,"i45":10,"i46":10,"i47":10,"i48":10,"i49":10,"i50":9,"i51":9,"i52":10,"i53":10,"i54":9,"i55":9,"i56":10,"i57":10,"i58":10,"i59":9,"i60":9,"i61":10,"i62":10};
|
|
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
|
var altColor = "altColor";
|
|
var rowColor = "rowColor";
|
|
var tableTab = "tableTab";
|
|
var activeTableTab = "activeTableTab";
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a name="navbar.top">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.top.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../org/json/package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="class-use/JSONObject.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>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../org/json/JSONML.html" title="class in org.json"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../org/json/JSONString.html" title="interface in org.json"><span class="typeNameLink">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../index.html?org/json/JSONObject.html" target="_top">Frames</a></li>
|
|
<li><a href="JSONObject.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="../../allclasses-noframe.html">All Classes</a></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>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li><a href="#field.summary">Field</a> | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li><a href="#field.detail">Field</a> | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip.navbar.top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<div class="header">
|
|
<div class="subTitle">org.json</div>
|
|
<h2 title="Class JSONObject" class="title">Class JSONObject</h2>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<ul class="inheritance">
|
|
<li>java.lang.Object</li>
|
|
<li>
|
|
<ul class="inheritance">
|
|
<li>org.json.JSONObject</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="description">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<hr>
|
|
<br>
|
|
<pre>public class <span class="typeNameLabel">JSONObject</span>
|
|
extends java.lang.Object</pre>
|
|
<div class="block">A JSONObject is an unordered collection of name/value pairs. Its external
|
|
form is a string wrapped in curly braces with colons between the names and
|
|
values, and commas between the values and names. The internal form is an
|
|
object having <code>get</code> and <code>opt</code> methods for accessing
|
|
the values by name, and <code>put</code> methods for adding or replacing
|
|
values by name. The values can be any of these types: <code>Boolean</code>,
|
|
<code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
|
|
<code>String</code>, or the <code>JSONObject.NULL</code> object. A
|
|
JSONObject constructor can be used to convert an external form JSON text
|
|
into an internal form whose values can be retrieved with the
|
|
<code>get</code> and <code>opt</code> methods, or to convert values into a
|
|
JSON text using the <code>put</code> and <code>toString</code> methods. A
|
|
<code>get</code> method returns a value if one can be found, and throws an
|
|
exception if one cannot be found. An <code>opt</code> method returns a
|
|
default value instead of throwing an exception, and so is useful for
|
|
obtaining optional values.
|
|
<p>
|
|
The generic <code>get()</code> and <code>opt()</code> methods return an
|
|
object, which you can cast or query for type. There are also typed
|
|
<code>get</code> and <code>opt</code> methods that do type checking and type
|
|
coercion for you. The opt methods differ from the get methods in that they
|
|
do not throw. Instead, they return a specified value, such as null.
|
|
<p>
|
|
The <code>put</code> methods add or replace values in an object. For
|
|
example,
|
|
|
|
<pre>
|
|
myString = new JSONObject()
|
|
.put("JSON", "Hello, World!").toString();
|
|
</pre>
|
|
|
|
produces the string <code>{"JSON": "Hello, World"}</code>.
|
|
<p>
|
|
The texts produced by the <code>toString</code> methods strictly conform to
|
|
the JSON syntax rules. The constructors are more forgiving in the texts they
|
|
will accept:
|
|
<ul>
|
|
<li>An extra <code>,</code> <small>(comma)</small> may appear just
|
|
before the closing brace.</li>
|
|
<li>Strings may be quoted with <code>'</code> <small>(single
|
|
quote)</small>.</li>
|
|
<li>Strings do not need to be quoted at all if they do not begin with a
|
|
quote or single quote, and if they do not contain leading or trailing
|
|
spaces, and if they do not contain any of these characters:
|
|
<code>{ } [ ] / \ : , #</code> and if they do not look like numbers and
|
|
if they are not the reserved words <code>true</code>, <code>false</code>,
|
|
or <code>null</code>.</li>
|
|
</ul></div>
|
|
<dl>
|
|
<dt><span class="simpleTagLabel">Version:</span></dt>
|
|
<dd>2016-02-08</dd>
|
|
<dt><span class="simpleTagLabel">Author:</span></dt>
|
|
<dd>JSON.org</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="summary">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- =========== FIELD SUMMARY =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="field.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
|
|
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colLast" scope="col">Field and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><code>static java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#NULL">NULL</a></span></code>
|
|
<div class="block">It is sometimes more convenient and less ambiguous to have a
|
|
<code>NULL</code> object than to use Java's <code>null</code> value.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
|
|
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colOne" scope="col">Constructor and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject--">JSONObject</a></span>()</code>
|
|
<div class="block">Construct an empty JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-org.json.JSONObject-java.lang.String:A-">JSONObject</a></span>(<a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> jo,
|
|
java.lang.String[] names)</code>
|
|
<div class="block">Construct a JSONObject from a subset of another JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-org.json.JSONTokener-">JSONObject</a></span>(<a href="../../org/json/JSONTokener.html" title="class in org.json">JSONTokener</a> x)</code>
|
|
<div class="block">Construct a JSONObject from a JSONTokener.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-java.util.Map-">JSONObject</a></span>(java.util.Map<?,?> map)</code>
|
|
<div class="block">Construct a JSONObject from a Map.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-java.lang.Object-">JSONObject</a></span>(java.lang.Object bean)</code>
|
|
<div class="block">Construct a JSONObject from an Object using bean getters.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-java.lang.Object-java.lang.String:A-">JSONObject</a></span>(java.lang.Object object,
|
|
java.lang.String[] names)</code>
|
|
<div class="block">Construct a JSONObject from an Object, using reflection to find the
|
|
public members.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-java.lang.String-">JSONObject</a></span>(java.lang.String source)</code>
|
|
<div class="block">Construct a JSONObject from a source JSON text string.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#JSONObject-java.lang.String-java.util.Locale-">JSONObject</a></span>(java.lang.String baseName,
|
|
java.util.Locale locale)</code>
|
|
<div class="block">Construct a JSONObject from a ResourceBundle.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
|
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colLast" scope="col">Method and Description</th>
|
|
</tr>
|
|
<tr id="i0" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#accumulate-java.lang.String-java.lang.Object-">accumulate</a></span>(java.lang.String key,
|
|
java.lang.Object value)</code>
|
|
<div class="block">Accumulate values under a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i1" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#append-java.lang.String-java.lang.Object-">append</a></span>(java.lang.String key,
|
|
java.lang.Object value)</code>
|
|
<div class="block">Append values to the array under a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i2" class="altColor">
|
|
<td class="colFirst"><code>static java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#doubleToString-double-">doubleToString</a></span>(double d)</code>
|
|
<div class="block">Produce a string from a double.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i3" class="rowColor">
|
|
<td class="colFirst"><code>java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#get-java.lang.String-">get</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the value object associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i4" class="altColor">
|
|
<td class="colFirst"><code>java.math.BigDecimal</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getBigDecimal-java.lang.String-">getBigDecimal</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the BigDecimal value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i5" class="rowColor">
|
|
<td class="colFirst"><code>java.math.BigInteger</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getBigInteger-java.lang.String-">getBigInteger</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the BigInteger value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i6" class="altColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getBoolean-java.lang.String-">getBoolean</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the boolean value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i7" class="rowColor">
|
|
<td class="colFirst"><code>double</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getDouble-java.lang.String-">getDouble</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the double value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i8" class="altColor">
|
|
<td class="colFirst"><code><E extends java.lang.Enum<E>><br>E</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getEnum-java.lang.Class-java.lang.String-">getEnum</a></span>(java.lang.Class<E> clazz,
|
|
java.lang.String key)</code>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i9" class="rowColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getInt-java.lang.String-">getInt</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the int value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i10" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getJSONArray-java.lang.String-">getJSONArray</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the JSONArray value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i11" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getJSONObject-java.lang.String-">getJSONObject</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the JSONObject value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i12" class="altColor">
|
|
<td class="colFirst"><code>long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getLong-java.lang.String-">getLong</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the long value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i13" class="rowColor">
|
|
<td class="colFirst"><code>static java.lang.String[]</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getNames-org.json.JSONObject-">getNames</a></span>(<a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> jo)</code>
|
|
<div class="block">Get an array of field names from a JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i14" class="altColor">
|
|
<td class="colFirst"><code>static java.lang.String[]</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getNames-java.lang.Object-">getNames</a></span>(java.lang.Object object)</code>
|
|
<div class="block">Get an array of field names from an Object.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i15" class="rowColor">
|
|
<td class="colFirst"><code>java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#getString-java.lang.String-">getString</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get the string associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i16" class="altColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#has-java.lang.String-">has</a></span>(java.lang.String key)</code>
|
|
<div class="block">Determine if the JSONObject contains a specific key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i17" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#increment-java.lang.String-">increment</a></span>(java.lang.String key)</code>
|
|
<div class="block">Increment a property of a JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i18" class="altColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#isNull-java.lang.String-">isNull</a></span>(java.lang.String key)</code>
|
|
<div class="block">Determine if the value associated with the key is null or if there is no
|
|
value.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i19" class="rowColor">
|
|
<td class="colFirst"><code>java.util.Iterator<java.lang.String></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#keys--">keys</a></span>()</code>
|
|
<div class="block">Get an enumeration of the keys of the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i20" class="altColor">
|
|
<td class="colFirst"><code>java.util.Set<java.lang.String></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#keySet--">keySet</a></span>()</code>
|
|
<div class="block">Get a set of keys of the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i21" class="rowColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#length--">length</a></span>()</code>
|
|
<div class="block">Get the number of keys stored in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i22" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#names--">names</a></span>()</code>
|
|
<div class="block">Produce a JSONArray containing the names of the elements of this
|
|
JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i23" class="rowColor">
|
|
<td class="colFirst"><code>static java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#numberToString-java.lang.Number-">numberToString</a></span>(java.lang.Number number)</code>
|
|
<div class="block">Produce a string from a Number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i24" class="altColor">
|
|
<td class="colFirst"><code>java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#opt-java.lang.String-">opt</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i25" class="rowColor">
|
|
<td class="colFirst"><code>java.math.BigDecimal</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optBigDecimal-java.lang.String-java.math.BigDecimal-">optBigDecimal</a></span>(java.lang.String key,
|
|
java.math.BigDecimal defaultValue)</code>
|
|
<div class="block">Get an optional BigDecimal associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i26" class="altColor">
|
|
<td class="colFirst"><code>java.math.BigInteger</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optBigInteger-java.lang.String-java.math.BigInteger-">optBigInteger</a></span>(java.lang.String key,
|
|
java.math.BigInteger defaultValue)</code>
|
|
<div class="block">Get an optional BigInteger associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i27" class="rowColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optBoolean-java.lang.String-">optBoolean</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional boolean associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i28" class="altColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optBoolean-java.lang.String-boolean-">optBoolean</a></span>(java.lang.String key,
|
|
boolean defaultValue)</code>
|
|
<div class="block">Get an optional boolean associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i29" class="rowColor">
|
|
<td class="colFirst"><code>double</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optDouble-java.lang.String-">optDouble</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional double associated with a key, or NaN if there is no such
|
|
key or if its value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i30" class="altColor">
|
|
<td class="colFirst"><code>double</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optDouble-java.lang.String-double-">optDouble</a></span>(java.lang.String key,
|
|
double defaultValue)</code>
|
|
<div class="block">Get an optional double associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i31" class="rowColor">
|
|
<td class="colFirst"><code><E extends java.lang.Enum<E>><br>E</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optEnum-java.lang.Class-java.lang.String-">optEnum</a></span>(java.lang.Class<E> clazz,
|
|
java.lang.String key)</code>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i32" class="altColor">
|
|
<td class="colFirst"><code><E extends java.lang.Enum<E>><br>E</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optEnum-java.lang.Class-java.lang.String-E-">optEnum</a></span>(java.lang.Class<E> clazz,
|
|
java.lang.String key,
|
|
E defaultValue)</code>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i33" class="rowColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optInt-java.lang.String-">optInt</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional int value associated with a key, or zero if there is no
|
|
such key or if the value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i34" class="altColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optInt-java.lang.String-int-">optInt</a></span>(java.lang.String key,
|
|
int defaultValue)</code>
|
|
<div class="block">Get an optional int value associated with a key, or the default if there
|
|
is no such key or if the value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i35" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optJSONArray-java.lang.String-">optJSONArray</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional JSONArray associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i36" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optJSONObject-java.lang.String-">optJSONObject</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional JSONObject associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i37" class="rowColor">
|
|
<td class="colFirst"><code>long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optLong-java.lang.String-">optLong</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional long value associated with a key, or zero if there is no
|
|
such key or if the value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i38" class="altColor">
|
|
<td class="colFirst"><code>long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optLong-java.lang.String-long-">optLong</a></span>(java.lang.String key,
|
|
long defaultValue)</code>
|
|
<div class="block">Get an optional long value associated with a key, or the default if there
|
|
is no such key or if the value is not a number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i39" class="rowColor">
|
|
<td class="colFirst"><code>java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optString-java.lang.String-">optString</a></span>(java.lang.String key)</code>
|
|
<div class="block">Get an optional string associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i40" class="altColor">
|
|
<td class="colFirst"><code>java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#optString-java.lang.String-java.lang.String-">optString</a></span>(java.lang.String key,
|
|
java.lang.String defaultValue)</code>
|
|
<div class="block">Get an optional string associated with a key.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i41" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-boolean-">put</a></span>(java.lang.String key,
|
|
boolean value)</code>
|
|
<div class="block">Put a key/boolean pair in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i42" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-java.util.Collection-">put</a></span>(java.lang.String key,
|
|
java.util.Collection<?> value)</code>
|
|
<div class="block">Put a key/value pair in the JSONObject, where the value will be a
|
|
JSONArray which is produced from a Collection.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i43" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-double-">put</a></span>(java.lang.String key,
|
|
double value)</code>
|
|
<div class="block">Put a key/double pair in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i44" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-int-">put</a></span>(java.lang.String key,
|
|
int value)</code>
|
|
<div class="block">Put a key/int pair in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i45" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-long-">put</a></span>(java.lang.String key,
|
|
long value)</code>
|
|
<div class="block">Put a key/long pair in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i46" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-java.util.Map-">put</a></span>(java.lang.String key,
|
|
java.util.Map<?,?> value)</code>
|
|
<div class="block">Put a key/value pair in the JSONObject, where the value will be a
|
|
JSONObject which is produced from a Map.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i47" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#put-java.lang.String-java.lang.Object-">put</a></span>(java.lang.String key,
|
|
java.lang.Object value)</code>
|
|
<div class="block">Put a key/value pair in the JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i48" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#putOnce-java.lang.String-java.lang.Object-">putOnce</a></span>(java.lang.String key,
|
|
java.lang.Object value)</code>
|
|
<div class="block">Put a key/value pair in the JSONObject, but only if the key and the value
|
|
are both non-null, and only if there is not already a member with that
|
|
name.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i49" class="rowColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#putOpt-java.lang.String-java.lang.Object-">putOpt</a></span>(java.lang.String key,
|
|
java.lang.Object value)</code>
|
|
<div class="block">Put a key/value pair in the JSONObject, but only if the key and the value
|
|
are both non-null.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i50" class="altColor">
|
|
<td class="colFirst"><code>static java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#quote-java.lang.String-">quote</a></span>(java.lang.String string)</code>
|
|
<div class="block">Produce a string in double quotes with backslash sequences in all the
|
|
right places.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i51" class="rowColor">
|
|
<td class="colFirst"><code>static java.io.Writer</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#quote-java.lang.String-java.io.Writer-">quote</a></span>(java.lang.String string,
|
|
java.io.Writer w)</code> </td>
|
|
</tr>
|
|
<tr id="i52" class="altColor">
|
|
<td class="colFirst"><code>java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#remove-java.lang.String-">remove</a></span>(java.lang.String key)</code>
|
|
<div class="block">Remove a name and its value, if present.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i53" class="rowColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#similar-java.lang.Object-">similar</a></span>(java.lang.Object other)</code>
|
|
<div class="block">Determine if two JSONObjects are similar.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i54" class="altColor">
|
|
<td class="colFirst"><code>static java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#stringToValue-java.lang.String-">stringToValue</a></span>(java.lang.String string)</code>
|
|
<div class="block">Try to convert a string into a number, boolean, or null.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i55" class="rowColor">
|
|
<td class="colFirst"><code>static void</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#testValidity-java.lang.Object-">testValidity</a></span>(java.lang.Object o)</code>
|
|
<div class="block">Throw an exception if the object is a NaN or infinite number.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i56" class="altColor">
|
|
<td class="colFirst"><code><a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#toJSONArray-org.json.JSONArray-">toJSONArray</a></span>(<a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> names)</code>
|
|
<div class="block">Produce a JSONArray containing the values of the members of this
|
|
JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i57" class="rowColor">
|
|
<td class="colFirst"><code>java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#toString--">toString</a></span>()</code>
|
|
<div class="block">Make a JSON text of this JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i58" class="altColor">
|
|
<td class="colFirst"><code>java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#toString-int-">toString</a></span>(int indentFactor)</code>
|
|
<div class="block">Make a prettyprinted JSON text of this JSONObject.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i59" class="rowColor">
|
|
<td class="colFirst"><code>static java.lang.String</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#valueToString-java.lang.Object-">valueToString</a></span>(java.lang.Object value)</code>
|
|
<div class="block">Make a JSON text of an Object value.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i60" class="altColor">
|
|
<td class="colFirst"><code>static java.lang.Object</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#wrap-java.lang.Object-">wrap</a></span>(java.lang.Object object)</code>
|
|
<div class="block">Wrap an object, if necessary.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i61" class="rowColor">
|
|
<td class="colFirst"><code>java.io.Writer</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#write-java.io.Writer-">write</a></span>(java.io.Writer writer)</code>
|
|
<div class="block">Write the contents of the JSONObject as JSON text to a writer.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i62" class="altColor">
|
|
<td class="colFirst"><code>java.io.Writer</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../org/json/JSONObject.html#write-java.io.Writer-int-int-">write</a></span>(java.io.Writer writer,
|
|
int indentFactor,
|
|
int indent)</code>
|
|
<div class="block">Write the contents of the JSONObject as JSON text to a writer.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Methods inherited from class java.lang.Object</h3>
|
|
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</code></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="details">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ============ FIELD DETAIL =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="field.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Detail</h3>
|
|
<a name="NULL">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>NULL</h4>
|
|
<pre>public static final java.lang.Object NULL</pre>
|
|
<div class="block">It is sometimes more convenient and less ambiguous to have a
|
|
<code>NULL</code> object than to use Java's <code>null</code> value.
|
|
<code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
|
|
<code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.</div>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Detail</h3>
|
|
<a name="JSONObject--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject()</pre>
|
|
<div class="block">Construct an empty JSONObject.</div>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-org.json.JSONObject-java.lang.String:A-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(<a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> jo,
|
|
java.lang.String[] names)</pre>
|
|
<div class="block">Construct a JSONObject from a subset of another JSONObject. An array of
|
|
strings is used to identify the keys that should be copied. Missing keys
|
|
are ignored.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>jo</code> - A JSONObject.</dd>
|
|
<dd><code>names</code> - An array of strings.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-org.json.JSONTokener-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(<a href="../../org/json/JSONTokener.html" title="class in org.json">JSONTokener</a> x)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Construct a JSONObject from a JSONTokener.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>x</code> - A JSONTokener object containing the source string.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If there is a syntax error in the source string or a
|
|
duplicated key.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-java.util.Map-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(java.util.Map<?,?> map)</pre>
|
|
<div class="block">Construct a JSONObject from a Map.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>map</code> - A map object that can be used to initialize the contents of
|
|
the JSONObject.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(java.lang.Object bean)</pre>
|
|
<div class="block">Construct a JSONObject from an Object using bean getters. It reflects on
|
|
all of the public methods of the object. For each of the methods with no
|
|
parameters and a name starting with <code>"get"</code> or
|
|
<code>"is"</code> followed by an uppercase letter, the method is invoked,
|
|
and a key and the value returned from the getter method are put into the
|
|
new JSONObject.
|
|
|
|
The key is formed by removing the <code>"get"</code> or <code>"is"</code>
|
|
prefix. If the second remaining character is not upper case, then the
|
|
first character is converted to lower case.
|
|
|
|
For example, if an object has a method named <code>"getName"</code>, and
|
|
if the result of calling <code>object.getName()</code> is
|
|
<code>"Larry Fine"</code>, then the JSONObject will contain
|
|
<code>"name": "Larry Fine"</code>.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>bean</code> - An object that has getter methods that should be used to make
|
|
a JSONObject.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-java.lang.Object-java.lang.String:A-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(java.lang.Object object,
|
|
java.lang.String[] names)</pre>
|
|
<div class="block">Construct a JSONObject from an Object, using reflection to find the
|
|
public members. The resulting JSONObject's keys will be the strings from
|
|
the names array, and the values will be the field values associated with
|
|
those keys in the object. If a key is not found or not visible, then it
|
|
will not be copied into the new JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>object</code> - An object that has fields that should be used to make a
|
|
JSONObject.</dd>
|
|
<dd><code>names</code> - An array of strings, the names of the fields to be obtained
|
|
from the object.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(java.lang.String source)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Construct a JSONObject from a source JSON text string. This is the most
|
|
commonly used JSONObject constructor.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>source</code> - A string beginning with <code>{</code> <small>(left
|
|
brace)</small> and ending with <code>}</code>
|
|
<small>(right brace)</small>.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If there is a syntax error in the source string or a
|
|
duplicated key.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="JSONObject-java.lang.String-java.util.Locale-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>JSONObject</h4>
|
|
<pre>public JSONObject(java.lang.String baseName,
|
|
java.util.Locale locale)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Construct a JSONObject from a ResourceBundle.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>baseName</code> - The ResourceBundle base name.</dd>
|
|
<dd><code>locale</code> - The Locale to load the ResourceBundle for.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If any JSONExceptions are detected.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Detail</h3>
|
|
<a name="accumulate-java.lang.String-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>accumulate</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> accumulate(java.lang.String key,
|
|
java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Accumulate values under a key. It is similar to the put method except
|
|
that if there is already an object stored under the key then a JSONArray
|
|
is stored under the key to hold all of the accumulated values. If there
|
|
is already a JSONArray, then the new value is appended to it. In
|
|
contrast, the put method replaces the previous value.
|
|
|
|
If only one value is accumulated that is not a JSONArray, then the result
|
|
will be the same as using put. But if multiple values are accumulated,
|
|
then the result will be like append.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - An object to be accumulated under the key.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the value is an invalid number or if the key is null.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="append-java.lang.String-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>append</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> append(java.lang.String key,
|
|
java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Append values to the array under a key. If the key does not exist in the
|
|
JSONObject, then the key is put in the JSONObject with its value being a
|
|
JSONArray containing the value parameter. If the key was already
|
|
associated with a JSONArray, then the value parameter is appended to it.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - An object to be accumulated under the key.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the key is null or if the current value associated with
|
|
the key is not a JSONArray.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="doubleToString-double-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>doubleToString</h4>
|
|
<pre>public static java.lang.String doubleToString(double d)</pre>
|
|
<div class="block">Produce a string from a double. The string "null" will be returned if the
|
|
number is not finite.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>d</code> - A double.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A String.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="get-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>get</h4>
|
|
<pre>public java.lang.Object get(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the value object associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The object associated with the key.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getEnum-java.lang.Class-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getEnum</h4>
|
|
<pre>public <E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> clazz,
|
|
java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>clazz</code> - The type of enum to retrieve.</dd>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The enum value associated with the key</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value cannot be converted
|
|
to an enum.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getBoolean-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getBoolean</h4>
|
|
<pre>public boolean getBoolean(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the boolean value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The truth.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the value is not a Boolean or the String "true" or
|
|
"false".</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getBigInteger-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getBigInteger</h4>
|
|
<pre>public java.math.BigInteger getBigInteger(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the BigInteger value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The numeric value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value cannot
|
|
be converted to BigInteger.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getBigDecimal-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getBigDecimal</h4>
|
|
<pre>public java.math.BigDecimal getBigDecimal(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the BigDecimal value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The numeric value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value
|
|
cannot be converted to BigDecimal.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getDouble-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getDouble</h4>
|
|
<pre>public double getDouble(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the double value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The numeric value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value is not a Number
|
|
object and cannot be converted to a number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getInt-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getInt</h4>
|
|
<pre>public int getInt(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the int value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The integer value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value cannot be converted
|
|
to an integer.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getJSONArray-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getJSONArray</h4>
|
|
<pre>public <a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> getJSONArray(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the JSONArray value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONArray which is the value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value is not a JSONArray.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getJSONObject-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getJSONObject</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> getJSONObject(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the JSONObject value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONObject which is the value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value is not a JSONObject.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getLong-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getLong</h4>
|
|
<pre>public long getLong(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the long value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The long value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is not found or if the value cannot be converted
|
|
to a long.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getNames-org.json.JSONObject-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getNames</h4>
|
|
<pre>public static java.lang.String[] getNames(<a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> jo)</pre>
|
|
<div class="block">Get an array of field names from a JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An array of field names, or null if there are no names.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getNames-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getNames</h4>
|
|
<pre>public static java.lang.String[] getNames(java.lang.Object object)</pre>
|
|
<div class="block">Get an array of field names from an Object.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An array of field names, or null if there are no names.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getString-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getString</h4>
|
|
<pre>public java.lang.String getString(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Get the string associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A string which is the value.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if there is no string value for the key.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="has-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>has</h4>
|
|
<pre>public boolean has(java.lang.String key)</pre>
|
|
<div class="block">Determine if the JSONObject contains a specific key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the key exists in the JSONObject.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="increment-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>increment</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> increment(java.lang.String key)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Increment a property of a JSONObject. If there is no such property,
|
|
create one with a value of 1. If there is such a property, and if it is
|
|
an Integer, Long, Double, or Float, then add one to it.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If there is already a property with this name that is not an
|
|
Integer, Long, Double, or Float.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="isNull-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>isNull</h4>
|
|
<pre>public boolean isNull(java.lang.String key)</pre>
|
|
<div class="block">Determine if the value associated with the key is null or if there is no
|
|
value.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if there is no value associated with the key or if the value
|
|
is the JSONObject.NULL object.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="keys--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>keys</h4>
|
|
<pre>public java.util.Iterator<java.lang.String> keys()</pre>
|
|
<div class="block">Get an enumeration of the keys of the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An iterator of the keys.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="keySet--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>keySet</h4>
|
|
<pre>public java.util.Set<java.lang.String> keySet()</pre>
|
|
<div class="block">Get a set of keys of the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A keySet.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="length--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>length</h4>
|
|
<pre>public int length()</pre>
|
|
<div class="block">Get the number of keys stored in the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The number of keys in the JSONObject.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="names--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>names</h4>
|
|
<pre>public <a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> names()</pre>
|
|
<div class="block">Produce a JSONArray containing the names of the elements of this
|
|
JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONArray containing the key strings, or null if the JSONObject
|
|
is empty.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="numberToString-java.lang.Number-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>numberToString</h4>
|
|
<pre>public static java.lang.String numberToString(java.lang.Number number)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Produce a string from a Number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>number</code> - A Number</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A String.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If n is a non-finite number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="opt-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>opt</h4>
|
|
<pre>public java.lang.Object opt(java.lang.String key)</pre>
|
|
<div class="block">Get an optional value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value, or null if there is no value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optEnum-java.lang.Class-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optEnum</h4>
|
|
<pre>public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz,
|
|
java.lang.String key)</pre>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>clazz</code> - The type of enum to retrieve.</dd>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The enum value associated with the key or null if not found</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optEnum-java.lang.Class-java.lang.String-java.lang.Enum-">
|
|
<!-- -->
|
|
</a><a name="optEnum-java.lang.Class-java.lang.String-E-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optEnum</h4>
|
|
<pre>public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz,
|
|
java.lang.String key,
|
|
E defaultValue)</pre>
|
|
<div class="block">Get the enum value associated with a key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>clazz</code> - The type of enum to retrieve.</dd>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default in case the value is not found</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The enum value associated with the key or defaultValue
|
|
if the value is not found or cannot be assigned to clazz</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optBoolean-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optBoolean</h4>
|
|
<pre>public boolean optBoolean(java.lang.String key)</pre>
|
|
<div class="block">Get an optional boolean associated with a key. It returns false if there
|
|
is no such key, or if the value is not Boolean.TRUE or the String "true".</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The truth.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optBoolean-java.lang.String-boolean-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optBoolean</h4>
|
|
<pre>public boolean optBoolean(java.lang.String key,
|
|
boolean defaultValue)</pre>
|
|
<div class="block">Get an optional boolean associated with a key. It returns the
|
|
defaultValue if there is no such key, or if it is not a Boolean or the
|
|
String "true" or "false" (case insensitive).</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The truth.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optDouble-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optDouble</h4>
|
|
<pre>public double optDouble(java.lang.String key)</pre>
|
|
<div class="block">Get an optional double associated with a key, or NaN if there is no such
|
|
key or if its value is not a number. If the value is a string, an attempt
|
|
will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A string which is the key.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optBigInteger-java.lang.String-java.math.BigInteger-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optBigInteger</h4>
|
|
<pre>public java.math.BigInteger optBigInteger(java.lang.String key,
|
|
java.math.BigInteger defaultValue)</pre>
|
|
<div class="block">Get an optional BigInteger associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number. If the value is a
|
|
string, an attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optBigDecimal-java.lang.String-java.math.BigDecimal-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optBigDecimal</h4>
|
|
<pre>public java.math.BigDecimal optBigDecimal(java.lang.String key,
|
|
java.math.BigDecimal defaultValue)</pre>
|
|
<div class="block">Get an optional BigDecimal associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number. If the value is a
|
|
string, an attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optDouble-java.lang.String-double-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optDouble</h4>
|
|
<pre>public double optDouble(java.lang.String key,
|
|
double defaultValue)</pre>
|
|
<div class="block">Get an optional double associated with a key, or the defaultValue if
|
|
there is no such key or if its value is not a number. If the value is a
|
|
string, an attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optInt-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optInt</h4>
|
|
<pre>public int optInt(java.lang.String key)</pre>
|
|
<div class="block">Get an optional int value associated with a key, or zero if there is no
|
|
such key or if the value is not a number. If the value is a string, an
|
|
attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optInt-java.lang.String-int-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optInt</h4>
|
|
<pre>public int optInt(java.lang.String key,
|
|
int defaultValue)</pre>
|
|
<div class="block">Get an optional int value associated with a key, or the default if there
|
|
is no such key or if the value is not a number. If the value is a string,
|
|
an attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optJSONArray-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optJSONArray</h4>
|
|
<pre>public <a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> optJSONArray(java.lang.String key)</pre>
|
|
<div class="block">Get an optional JSONArray associated with a key. It returns null if there
|
|
is no such key, or if its value is not a JSONArray.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONArray which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optJSONObject-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optJSONObject</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> optJSONObject(java.lang.String key)</pre>
|
|
<div class="block">Get an optional JSONObject associated with a key. It returns null if
|
|
there is no such key, or if its value is not a JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONObject which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optLong-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optLong</h4>
|
|
<pre>public long optLong(java.lang.String key)</pre>
|
|
<div class="block">Get an optional long value associated with a key, or zero if there is no
|
|
such key or if the value is not a number. If the value is a string, an
|
|
attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optLong-java.lang.String-long-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optLong</h4>
|
|
<pre>public long optLong(java.lang.String key,
|
|
long defaultValue)</pre>
|
|
<div class="block">Get an optional long value associated with a key, or the default if there
|
|
is no such key or if the value is not a number. If the value is a string,
|
|
an attempt will be made to evaluate it as a number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>An object which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optString-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optString</h4>
|
|
<pre>public java.lang.String optString(java.lang.String key)</pre>
|
|
<div class="block">Get an optional string associated with a key. It returns an empty string
|
|
if there is no such key. If the value is not a string and is not null,
|
|
then it is converted to a string.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A string which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="optString-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>optString</h4>
|
|
<pre>public java.lang.String optString(java.lang.String key,
|
|
java.lang.String defaultValue)</pre>
|
|
<div class="block">Get an optional string associated with a key. It returns the defaultValue
|
|
if there is no such key.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>defaultValue</code> - The default.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A string which is the value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-boolean-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
boolean value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/boolean pair in the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - A boolean which is the value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the key is null.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-java.util.Collection-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
java.util.Collection<?> value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/value pair in the JSONObject, where the value will be a
|
|
JSONArray which is produced from a Collection.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - A Collection value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-double-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
double value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/double pair in the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - A double which is the value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the key is null or if the number is invalid.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-int-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
int value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/int pair in the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - An int which is the value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the key is null.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-long-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
long value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/long pair in the JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - A long which is the value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the key is null.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-java.util.Map-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
java.util.Map<?,?> value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/value pair in the JSONObject, where the value will be a
|
|
JSONObject which is produced from a Map.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - A Map value.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="put-java.lang.String-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>put</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> put(java.lang.String key,
|
|
java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/value pair in the JSONObject. If the value is null, then the
|
|
key will be removed from the JSONObject if it is present.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - An object which is the value. It should be of one of these
|
|
types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
|
|
String, or the JSONObject.NULL object.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the value is non-finite number or if the key is null.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="putOnce-java.lang.String-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>putOnce</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> putOnce(java.lang.String key,
|
|
java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/value pair in the JSONObject, but only if the key and the value
|
|
are both non-null, and only if there is not already a member with that
|
|
name.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - string</dd>
|
|
<dd><code>value</code> - object</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - if the key is a duplicate</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="putOpt-java.lang.String-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>putOpt</h4>
|
|
<pre>public <a href="../../org/json/JSONObject.html" title="class in org.json">JSONObject</a> putOpt(java.lang.String key,
|
|
java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Put a key/value pair in the JSONObject, but only if the key and the value
|
|
are both non-null.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - A key string.</dd>
|
|
<dd><code>value</code> - An object which is the value. It should be of one of these
|
|
types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
|
|
String, or the JSONObject.NULL object.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>this.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the value is a non-finite number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="quote-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>quote</h4>
|
|
<pre>public static java.lang.String quote(java.lang.String string)</pre>
|
|
<div class="block">Produce a string in double quotes with backslash sequences in all the
|
|
right places. A backslash will be inserted within </, producing <\/,
|
|
allowing JSON text to be delivered in HTML. In JSON text, a string cannot
|
|
contain a control character or an unescaped quote or backslash.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>string</code> - A String</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A String correctly formatted for insertion in a JSON text.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="quote-java.lang.String-java.io.Writer-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>quote</h4>
|
|
<pre>public static java.io.Writer quote(java.lang.String string,
|
|
java.io.Writer w)
|
|
throws java.io.IOException</pre>
|
|
<dl>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code>java.io.IOException</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="remove-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>remove</h4>
|
|
<pre>public java.lang.Object remove(java.lang.String key)</pre>
|
|
<div class="block">Remove a name and its value, if present.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>key</code> - The name to be removed.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The value that was associated with the name, or null if there was
|
|
no value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="similar-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>similar</h4>
|
|
<pre>public boolean similar(java.lang.Object other)</pre>
|
|
<div class="block">Determine if two JSONObjects are similar.
|
|
They must contain the same set of names which must be associated with
|
|
similar values.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>other</code> - The other JSONObject</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if they are equal</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="stringToValue-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>stringToValue</h4>
|
|
<pre>public static java.lang.Object stringToValue(java.lang.String string)</pre>
|
|
<div class="block">Try to convert a string into a number, boolean, or null. If the string
|
|
can't be converted, return the string.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>string</code> - A String.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A simple JSON value.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="testValidity-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>testValidity</h4>
|
|
<pre>public static void testValidity(java.lang.Object o)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Throw an exception if the object is a NaN or infinite number.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>o</code> - The object to test.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If o is a non-finite number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="toJSONArray-org.json.JSONArray-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>toJSONArray</h4>
|
|
<pre>public <a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> toJSONArray(<a href="../../org/json/JSONArray.html" title="class in org.json">JSONArray</a> names)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Produce a JSONArray containing the values of the members of this
|
|
JSONObject.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>names</code> - A JSONArray containing a list of key strings. This determines
|
|
the sequence of the values in the result.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>A JSONArray of values.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If any of the values are non-finite numbers.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="toString--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>toString</h4>
|
|
<pre>public java.lang.String toString()</pre>
|
|
<div class="block">Make a JSON text of this JSONObject. For compactness, no whitespace is
|
|
added. If this would not result in a syntactically correct JSON text,
|
|
then null will be returned instead.
|
|
<p>
|
|
Warning: This method assumes that the data structure is acyclical.</div>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>toString</code> in class <code>java.lang.Object</code></dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>a printable, displayable, portable, transmittable representation
|
|
of the object, beginning with <code>{</code> <small>(left
|
|
brace)</small> and ending with <code>}</code> <small>(right
|
|
brace)</small>.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="toString-int-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>toString</h4>
|
|
<pre>public java.lang.String toString(int indentFactor)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Make a prettyprinted JSON text of this JSONObject.
|
|
<p>
|
|
Warning: This method assumes that the data structure is acyclical.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>indentFactor</code> - The number of spaces to add to each level of indentation.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>a printable, displayable, portable, transmittable representation
|
|
of the object, beginning with <code>{</code> <small>(left
|
|
brace)</small> and ending with <code>}</code> <small>(right
|
|
brace)</small>.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the object contains an invalid number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="valueToString-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>valueToString</h4>
|
|
<pre>public static java.lang.String valueToString(java.lang.Object value)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Make a JSON text of an Object value. If the object has an
|
|
value.toJSONString() method, then that method will be used to produce the
|
|
JSON text. The method is required to produce a strictly conforming text.
|
|
If the object does not contain a toJSONString method (which is the most
|
|
common case), then a text will be produced by other means. If the value
|
|
is an array or Collection, then a JSONArray will be made from it and its
|
|
toJSONString method will be called. If the value is a MAP, then a
|
|
JSONObject will be made from it and its toJSONString method will be
|
|
called. Otherwise, the value's toString method will be called, and the
|
|
result will be quoted.
|
|
|
|
<p>
|
|
Warning: This method assumes that the data structure is acyclical.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>value</code> - The value to be serialized.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>a printable, displayable, transmittable representation of the
|
|
object, beginning with <code>{</code> <small>(left
|
|
brace)</small> and ending with <code>}</code> <small>(right
|
|
brace)</small>.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code> - If the value is or contains an invalid number.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="wrap-java.lang.Object-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>wrap</h4>
|
|
<pre>public static java.lang.Object wrap(java.lang.Object object)</pre>
|
|
<div class="block">Wrap an object, if necessary. If the object is null, return the NULL
|
|
object. If it is an array or collection, wrap it in a JSONArray. If it is
|
|
a map, wrap it in a JSONObject. If it is a standard property (Double,
|
|
String, et al) then it is already wrapped. Otherwise, if it comes from
|
|
one of the java packages, turn it into a string. And if it doesn't, try
|
|
to wrap it in a JSONObject. If the wrapping fails, then null is returned.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>object</code> - The object to wrap</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The wrapped value</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="write-java.io.Writer-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>write</h4>
|
|
<pre>public java.io.Writer write(java.io.Writer writer)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Write the contents of the JSONObject as JSON text to a writer. For
|
|
compactness, no whitespace is added.
|
|
<p>
|
|
Warning: This method assumes that the data structure is acyclical.</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The writer.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="write-java.io.Writer-int-int-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>write</h4>
|
|
<pre>public java.io.Writer write(java.io.Writer writer,
|
|
int indentFactor,
|
|
int indent)
|
|
throws <a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></pre>
|
|
<div class="block">Write the contents of the JSONObject as JSON text to a writer. For
|
|
compactness, no whitespace is added.
|
|
<p>
|
|
Warning: This method assumes that the data structure is acyclical.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>writer</code> - Writes the serialized JSON</dd>
|
|
<dd><code>indentFactor</code> - The number of spaces to add to each level of indentation.</dd>
|
|
<dd><code>indent</code> - The indention of the top level.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>The writer.</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="../../org/json/JSONException.html" title="class in org.json">JSONException</a></code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a name="navbar.bottom">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.bottom.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../org/json/package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="class-use/JSONObject.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>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../org/json/JSONML.html" title="class in org.json"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../org/json/JSONString.html" title="interface in org.json"><span class="typeNameLink">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../index.html?org/json/JSONObject.html" target="_top">Frames</a></li>
|
|
<li><a href="JSONObject.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="../../allclasses-noframe.html">All 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>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li><a href="#field.summary">Field</a> | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li><a href="#field.detail">Field</a> | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip.navbar.bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
<p class="legalCopy"><small>Copyright © 2016. All Rights Reserved.</small></p>
|
|
</body>
|
|
</html>
|