public class

JSONParser

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.encoding.json.parser.JSONParser

Class Overview

Parser for JSON text. Please note that JSONParser is NOT thread-safe.

Modified to support arbitrarily long integer json Numbers.

Summary

Constants
int S_END
int S_INIT
int S_IN_ARRAY
int S_IN_ERROR
int S_IN_FINISHED_VALUE
int S_IN_OBJECT
int S_IN_PAIR_VALUE
int S_PASSED_PAIR_KEY
Public Constructors
JSONParser()
Public Methods
long getPosition()
Object parse(Reader in)
Object parse(String s)
Object parse(String s, ContainerFactory containerFactory)
void parse(Reader in, ContentHandler contentHandler)
void parse(Reader in, ContentHandler contentHandler, boolean isResume)
Stream processing of JSON text.
void parse(String s, ContentHandler contentHandler)
void parse(String s, ContentHandler contentHandler, boolean isResume)
Object parse(Reader in, ContainerFactory containerFactory)
Parse JSON text into java object from the input source.
void reset(Reader in)
Reset the parser to the initial state with a new character reader.
void reset()
Reset the parser to the initial state without resetting the underlying reader.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int S_END

Constant Value: 6 (0x00000006)

public static final int S_INIT

Constant Value: 0 (0x00000000)

public static final int S_IN_ARRAY

Constant Value: 3 (0x00000003)

public static final int S_IN_ERROR

Constant Value: -1 (0xffffffff)

public static final int S_IN_FINISHED_VALUE

Constant Value: 1 (0x00000001)

public static final int S_IN_OBJECT

Constant Value: 2 (0x00000002)

public static final int S_IN_PAIR_VALUE

Constant Value: 5 (0x00000005)

public static final int S_PASSED_PAIR_KEY

Constant Value: 4 (0x00000004)

Public Constructors

public JSONParser ()

Public Methods

public long getPosition ()

Returns
  • The position of the beginning of the current token.

public Object parse (Reader in)

Throws
IOException
ParseException

public Object parse (String s)

public Object parse (String s, ContainerFactory containerFactory)

public void parse (Reader in, ContentHandler contentHandler)

Throws
IOException
ParseException

public void parse (Reader in, ContentHandler contentHandler, boolean isResume)

Stream processing of JSON text.

Parameters
isResume - Indicates if it continues previous parsing operation. If set to true, resume parsing the old stream, and parameter 'in' will be ignored. If this method is called for the first time in this instance, isResume will be ignored.
Throws
IOException
ParseException
IOException
See Also

public void parse (String s, ContentHandler contentHandler)

public void parse (String s, ContentHandler contentHandler, boolean isResume)

public Object parse (Reader in, ContainerFactory containerFactory)

Parse JSON text into java object from the input source.

Parameters
containerFactory - Use this factory to create your own JSON object and JSON array containers.
Returns
  • Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
Throws
IOException
ParseException
IOException

public void reset (Reader in)

Reset the parser to the initial state with a new character reader.

Parameters
in - The new character reader.
Throws
IOException
ParseException

public void reset ()

Reset the parser to the initial state without resetting the underlying reader.