lib/muskox/json_lexer.rb
# Parses the current JSON string _source_ and returns the complete data
# structure as a result.
Parses the current JSON string _source_ and returns the complete data
structure as a result.
Parses the current JSON string _source_ and returns the complete data structure as a result .
def lex &block
        @callback = block
        reset
        if @quirks_mode
          while !eos? && skip(IGNORE)
          end
          if eos?
            raise ParserError, "source did not contain any JSON!"
          else
            obj = lex_value
            obj == UNPARSED and raise ParserError, "source did not contain any JSON!"
          end
        else
          until eos?
            case
            when scan(OBJECT_OPEN)
              @current_nesting = 1
              lex_object
            when scan(ARRAY_OPEN)
              @current_nesting = 1
              lex_array
            when skip(IGNORE)
              ;
            else
              raise ParserError, "source '#{peek(20)}' not in JSON!"
            end
          end
        end
      end
def lex & block @callback = block reset if @quirks_mode while ! eos? && skip ( IGNORE ) end if eos? raise ParserError , "source did not contain any JSON!" else obj = lex_value obj == UNPARSED and raise ParserError , "source did not contain any JSON!" end else until eos? case when scan ( OBJECT_OPEN ) @current_nesting = 1 lex_object when scan ( ARRAY_OPEN ) @current_nesting = 1 lex_array when skip ( IGNORE ) ; else raise ParserError , "source '#{peek(20)}' not in JSON!" end end end end
Parses the current JSON string _source_ and returns the complete data
structure as a result.
Parses the current JSON string _source_ and returns the complete data structure as a result .
#              obj and raise ParserError, "source '#{peek(20)}' not in JSON!" #              obj and raise ParserError, "source '#{peek(20)}' not in JSON!" #          obj or raise ParserError, "source did not contain any JSON!" #        obj
block