Sha256: 4a8295bd0599372618845872c737a4cc01c2515c919d5710303b02fc9faadacf

Contents?: true

Size: 793 Bytes

Versions: 31

Compression:

Stored size: 793 Bytes

Contents

#!/usr/bin/env ruby

#!/usr/bin/env ruby
# encoding: UTF-8

$: << File.dirname(__FILE__)
%w(lib ext test).each do |dir|
  $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
end

require 'oj'
require 'stringio'

class Parser < Oj::Saj

  def parse(json)
    Oj.saj_parse(self, StringIO.new(json))
  end

  def hash_start(key)
    puts "START: #{key}"
  end

  def error(message, line, column)
    puts "Error callback: #{message}"
  end

end

parser = Parser.new

begin
  # truncated JSON, Oj.saj_parse raises, #error not called
  parser.parse('{"foo{"bar":')
rescue Exception => e
  puts "*** #{e.class}: #{e.message}"
end

puts "\n\n"

begin
  # invalid JSON, doesn't raise an error
  parser.parse('{"foo":{"bar":}')
rescue Exception => e
  puts "*** #{e.class}: #{e.message}"
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
oj-3.7.6 test/bug3.rb
oj-2.18.5 test/bug3.rb
oj-2.18.4 test/bug3.rb
oj-2.18.3 test/bug3.rb
oj-2.18.2 test/bug3.rb
oj-2.18.1 test/bug3.rb
oj-2.18.0 test/bug3.rb
oj-2.17.5 test/bug3.rb
oj-2.17.3 test/bug3.rb
oj-2.17.2 test/bug3.rb
oj-2.17.1 test/bug3.rb
oj-2.17.0 test/bug3.rb
oj-2.16.1 test/bug3.rb
oj-2.14.6 test/bug3.rb
oj-2.14.5 test/bug3.rb
oj-2.14.4 test/bug3.rb
oj-2.14.3 test/bug3.rb
oj-2.14.2 test/bug3.rb
oj-2.14.1 test/bug3.rb
oj-2.14.0 test/bug3.rb