Skip to content

Oj.sc_parse doesn't parse primitives types when Oj.mimic_JSON is called #979

@stanhu

Description

@stanhu

Here's my test case:

require 'oj'

class MyValidator < Oj::ScHandler
  def hash_start(); end
  def hash_end(); end
  def hash_key(key); end
  def hash_set(h, key, value); end
  def array_start(); end
  def array_end(); end
  def array_append(a, value); end
  def add_value(value); end
end

validator = MyValidator.new

Oj.mimic_JSON()

puts Oj.load('42')
puts Oj.sc_parse(validator, '42')

This fails with:

42
test.rb:19:in `sc_parse': Empty input (after ) at line 1, column 2 [parse.c:1074] in '42 (JSON::ParserError)
	from test.rb:19:in `<main>'

If I comment out mimic_JSON, then it works fine.

Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions