Sha256: 8cc7de3a08084f886ded565124ed0be40cfa9458dbefceb1751b8448e3000606

Contents?: true

Size: 477 Bytes

Versions: 6

Compression:

Stored size: 477 Bytes

Contents

require 'asir'

module ASIR
  class Coder
    # !SLIDE
    # JSON Coder
    #
    # Note: Symbols are not handled.
    # The actual JSON expression is wrapped with an Array.
    class JSON < self
      def _encode obj
        [ obj ].to_json
      end

      def _decode obj
        parser = ::JSON.parser.new(obj)
        ary = parser.parse
        ary.first
      end
    end
    # !SLIDE END
  end
end

if RUBY_PLATFORM =~ /java/
require 'json'
else
require 'json/ext'
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asir-1.0.7 lib/asir/coder/json.rb
asir-1.0.6 lib/asir/coder/json.rb
asir-1.0.5 lib/asir/coder/json.rb
asir-1.0.4 lib/asir/coder/json.rb
asir-1.0.1 lib/asir/coder/json.rb
asir-0.2.0 lib/asir/coder/json.rb