class StructuredReader::JSONReader
Public Class Methods
new(root: :object, reader_set: ReaderSet.new, &blk)
click to toggle source
# File lib/structured_reader.rb, line 22 def initialize(root: :object, reader_set: ReaderSet.new, &blk) @root_reader = reader_set.reader(root, &blk) end
Public Instance Methods
read(document, context = Context.new)
click to toggle source
# File lib/structured_reader.rb, line 26 def read(document, context = Context.new) if document.kind_of?(String) document = JSON.parse document end context.open do @root_reader.read(document, context) end end
validate(document)
click to toggle source
# File lib/structured_reader.rb, line 35 def validate(document) read(document, ValidatorContext.new) end