Sha256: 588737744a40fdac0adc30ec5d74745bce7c4b0a4a17ecd9b049b00fc8caf6f1

Contents?: true

Size: 1.5 KB

Versions: 148

Compression:

Stored size: 1.5 KB

Contents

module Oj
  # A SAX style parse handler for JSON hence the acronym SAJ for Simple API for
  # JSON. The Oj::Saj handler class should be subclassed and then used with the
  # Oj::Saj key_parse() method. The Saj methods will then be called as the file
  # is parsed.
  #
  # @example
  # 
  #  require 'oj'
  #
  #  class MySaj < ::Oj::Saj
  #    def initialize()
  #      @hash_cnt = 0
  #    end
  #
  #    def hash_start(key)
  #      @hash_cnt += 1
  #    end
  #  end
  #
  #  cnt = MySaj.new()
  #  File.open('any.json', 'r') do |f|
  #    Oj.saj_parse(cnt, f)
  #  end
  #
  # To make the desired methods active while parsing the desired method should
  # be made public in the subclasses. If the methods remain private they will
  # not be called during parsing.
  #
  #    def hash_start(key); end
  #    def hash_end(key); end
  #    def array_start(key); end
  #    def array_end(key); end
  #    def add_value(value, key); end
  #    def error(message, line, column); end
  #
  class Saj
    # Create a new instance of the Saj handler class.
    def initialize()
    end

    # To make the desired methods active while parsing the desired method should
    # be made public in the subclasses. If the methods remain private they will
    # not be called during parsing.
    private

    def hash_start(key)
    end

    def hash_end(key)
    end

    def array_start(key)
    end

    def array_end(key)
    end

    def add_value(value, key)
    end

    def error(message, line, column)
    end
    
  end # Saj
end # Oj

Version data entries

148 entries across 148 versions & 3 rubygems

Version Path
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/lib/oj/saj.rb
oj-3.13.15 lib/oj/saj.rb
oj-3.13.14 lib/oj/saj.rb
oj-3.13.13 lib/oj/saj.rb
oj-3.13.12 lib/oj/saj.rb
oj-3.13.11 lib/oj/saj.rb
oj-3.13.10 lib/oj/saj.rb
oj-3.13.9 lib/oj/saj.rb
oj-3.13.8 lib/oj/saj.rb
oj-3.13.7 lib/oj/saj.rb
oj-3.13.6 lib/oj/saj.rb
oj-3.13.5 lib/oj/saj.rb
oj-3.13.4 lib/oj/saj.rb
oj-3.13.3 lib/oj/saj.rb
oj-3.13.2 lib/oj/saj.rb
oj-3.13.1 lib/oj/saj.rb
oj-3.13.0 lib/oj/saj.rb
oj-3.12.3 lib/oj/saj.rb
oj-3.12.2 lib/oj/saj.rb
oj-3.12.1 lib/oj/saj.rb