Class JSONParser


  • public class JSONParser
    extends java.lang.Object
    Reads JSON text and convert it into a Java model for further handling.
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONParser​(java.io.InputStream aStream)
      Construct a parser using a stream.
      JSONParser​(java.io.InputStream aStream, java.lang.String aStreamName)
      Construct a parser using a stream.
      JSONParser​(java.io.Reader aReader)
      Construct a parser using a reader.
      JSONParser​(java.io.Reader aReader, java.lang.String aStreamName)
      Construct a parser using a reader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JSONValue nextValue()
      Read the next JSON structure from the stream and convert it into a Java model.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • streamName

        private java.lang.String streamName
    • Constructor Detail

      • JSONParser

        public JSONParser​(java.io.InputStream aStream,
                          java.lang.String aStreamName)
        Construct a parser using a stream.
        Parameters:
        aStream - A stream containing JSON text.
        aStreamName - A String that describes the stream, it will be attached to all JSON objects in the model which are generated from this parser. This makes it possible to identify the stream where the object came from.
      • JSONParser

        public JSONParser​(java.io.InputStream aStream)
        Construct a parser using a stream.
        Parameters:
        aStream - A stream containing JSON text.
      • JSONParser

        public JSONParser​(java.io.Reader aReader,
                          java.lang.String aStreamName)
        Construct a parser using a reader.
        Parameters:
        aReader - A reader containing JSON text.
        aStreamName - A String that describes the stream, it will be attached to all JSON objects in the model which are generated from this parser. This makes it possible to identify the stream where the object came from.
      • JSONParser

        public JSONParser​(java.io.Reader aReader)
        Construct a parser using a reader.
        Parameters:
        aReader - A reader containing JSON text.
    • Method Detail

      • nextValue

        public JSONValue nextValue()
                            throws antlr.TokenStreamException,
                                   antlr.RecognitionException
        Read the next JSON structure from the stream and convert it into a Java model.
        Returns:
        A Java object representing the object in the stream.
        Throws:
        antlr.TokenStreamException - A syntax error is encountered.
        antlr.RecognitionException - When a token could not be formed.