Sha256: cef03a9368cf88cd30ed051106d0aae497aac7dd8e7badba4dc496ec1bdd7408

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

module ChainReactor::Parsers

  # Parse the string as a JSON object.
  class JsonParser < Parser
    require 'json'

    # Parse a JSON string, returning the result as a hash.
    #
    # Raises a ParseError on failure.
    def do_parse(string)
      begin
        @log.debug { "Parsing JSON string #{string.inspect}" }
        JSON.parse(string)
      rescue JSON::ParserError => e
        raise ParseError, "Data from client is not a valid JSON: #{string}, error: #{e.message}, data: #{string}"
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chain-reactor-0.2.2 lib/chain-reactor/parsers/json_parser.rb
chain-reactor-0.2.1 lib/chain-reactor/parsers/json_parser.rb
chain-reactor-0.2.0 lib/chain-reactor/parsers/json_parser.rb