Sha256: c09ba045ee0e291dc770128e9e1199559f647a22c6ada208fbd22bc02f34805c
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'legion/json/version' require 'legion/json/parse_error' module Legion # Used to create JSON objects module JSON class << self # Set up the JSON parser. This method must be called before any # attempt to use the parser. This method is currently called at # the bottom of this file. The appropriate JSON parser will be # loaded for the current platform. # # @return [Object] parser. def setup! if RUBY_ENGINE == 'jruby' require 'legion/json/jrjackson' @parser = Legion::JSON::JrJackson.new else require 'legion/json/oj' @parser = Legion::JSON::Oj.new end end # Load (and parse) a JSON string. # # @param string [String] # @return [Object] def load(string) @parser.load(string) rescue StandardError => error raise Legion::JSON::ParseError.build(error, string) end # Dump (generate) a JSON string from a Ruby object. # # @param object [Object] # @param options [Hash] def dump(object, options = {}) @parser.dump(object, options) end end end end Legion::JSON.setup!
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
legion-json-0.1.0 | lib/legion/json.rb |