Share via


JSONTokener Class

Definition

Parses a JSON (RFC 4627) encoded string into the corresponding object.

[Android.Runtime.Register("org/json/JSONTokener", DoNotGenerateAcw=true)]
public class JSONTokener : Java.Lang.Object
[<Android.Runtime.Register("org/json/JSONTokener", DoNotGenerateAcw=true)>]
type JSONTokener = class
    inherit Object
Inheritance
JSONTokener
Attributes

Remarks

Parses a JSON (RFC 4627) encoded string into the corresponding object. Most clients of this class will use only need the #JSONTokener(String) constructor and #nextValue method. Example usage:

String json = "{"
                    + "  \"query\": \"Pizza\", "
                    + "  \"locations\": [ 94043, 90210 ] "
                    + "}";

            JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
            String query = object.getString("query");
            JSONArray locations = object.getJSONArray("locations");

For best interoperability and performance use JSON that complies with RFC 4627, such as that generated by JSONStringer. For legacy reasons this parser is lenient, so a successful parse does not indicate that the input string was valid JSON. All of the following syntax errors will be ignored: <ul> <li>End of line comments starting with // or # and ending with a newline character. <li>C-style comments starting with /* and ending with */. Such comments may not be nested. <li>Strings that are unquoted or 'single quoted'. <li>Hexadecimal integers prefixed with 0x or 0X. <li>Octal integers prefixed with 0. <li>Array elements separated by ;. <li>Unnecessary array separators. These are interpreted as if null was the omitted value. <li>Key-value pairs separated by = or =>. <li>Key-value pairs separated by ;. </ul>

Each tokener may be used to parse a single JSON string. Instances of this class are not thread safe. Although this class is nonfinal, it was not designed for inheritance and should not be subclassed. In particular, self-use by overrideable methods is not specified. See Effective Java Item 17, "Design and Document or inheritance or else prohibit it" for further information.

Java documentation for org.json.JSONTokener.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

JSONTokener(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

JSONTokener(String)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Back()

Unreads the most recent character of input.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dehexchar(Char)

Returns the integer [0.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
More()

Returns true until the input has been exhausted.

Next()

Returns the next available character, or the null character '\0' if all input has been exhausted.

Next(Char)

Returns the next available character if it equals c.

Next(Int32)

Returns the next length characters of the input.

NextClean()

Returns the next character that is not whitespace and does not belong to a comment.

NextString(Char)

Returns the string up to but not including quote, unescaping any character escape sequences encountered along the way.

NextTo(Char)

Equivalent to nextTo(String.valueOf(excluded)).

NextTo(String)

Returns the String#trim trimmed string holding the characters up to but not including the first of: <ul> <li>any character in excluded<li>a newline character '\n' <li>a carriage return '\r' </ul>

NextValue()

Returns the next value from the input.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SkipPast(String)

Advances past all input up to and including the next occurrence of thru.

SkipTo(Char)

Advances past all input up to but not including the next occurrence of to.

SyntaxError(String)

Returns an exception containing the given message plus the current position and the entire input string.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to