Class JSONLexer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class JSONLexer
    extends java.lang.Object
    implements java.io.Closeable
    Lexical analyzer for JSON, based on RFC 8259 (see also https://tools.ietf.org/html/rfc8259).

    Unlike traditional lexers, which are normally generated, this one is implemented by hand. A normal implementation would rely on a DFA, this one encapsulates substates in subroutines.

    • Constructor Summary

      Constructors 
      Constructor Description
      JSONLexer​(java.io.Reader input)
      Constructor taking a Reader from where to read the JSON data.
      JSONLexer​(java.lang.String input)
      Constructor taking the JSON string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      JSONToken nextToken()
      Get the next token, or null if no next token is available.
      • Methods inherited from class java.lang.Object

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

      • JSONLexer

        public JSONLexer​(java.lang.String input)
        Constructor taking the JSON string.
        Parameters:
        input - JSON string for lexical analysis.
      • JSONLexer

        public JSONLexer​(java.io.Reader input)
        Constructor taking a Reader from where to read the JSON data.
        Parameters:
        input - A Reader instance from where to read the JSON data.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException