Sha256: 6f732597952f514d534519c609cb66904e03f3cc3935d7000a798e60feb4ad4c
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
unless RUBY_PLATFORM =~ /java/ puts "This library is only compatible with a java-based ruby environment like JRuby." exit 255 end # require_relative "jars/jrjackson-1.2.1.jar" require_relative "jars/jrjackson-1.2.2.jar" require 'com/jrjackson/jr_jackson' module JrJackson module Json class << self TIME_REGEX = %r(\A(\d{4}-\d\d-\d\d|(\w{3}\s){2}\d\d)\s\d\d:\d\d:\d\d) def load(json_string, options = nil) if json_string.is_a?(String) && json_string =~ TIME_REGEX return JrJackson::Raw.parse_raw("\"#{json_string}\"") end if options && !options.empty? if options.size == 1 && !!options[:raw] return JrJackson::Raw.parse_raw(json_string) end if options.size == 1 && !!options[:symbolize_keys] return JrJackson::Raw.parse_sym(json_string) end JrJackson::Raw.parse(json_string, options) else JrJackson::Raw.parse_str(json_string) end end def dump(object) case object when Array, Hash, String JrJackson::Raw.generate(object) when true, false object.to_s when nil 'null' else if object.respond_to?(:to_json) object.to_json elsif object.respond_to?(:to_s) object.to_s else object end end end alias :parse :load alias :generate :dump end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jrjackson-0.2.0 | lib/jrjackson/jrjackson.rb |