lib/megam/core/json_compat.rb
# Just call the JSON gem's parse method with a modified :max_nesting field
Just call the JSON gem's parse method with a modified :max_nesting field
Just call the JSON gem ' s parse method with a modified : max_nesting field
def from_json(source, opts = {})
        obj = ::Yajl::Parser.parse(source)
        unless obj.kind_of?(Hash) or obj.kind_of?(Array)
          raise JSON::ParserError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
        end
        if opts[:create_additions].nil? || opts[:create_additions]
          map_to_rb_obj(obj)
        else
        obj
        end
      end
def from_json ( source , opts = { } ) obj = :: Yajl :: Parser . parse ( source ) unless obj . kind_of? ( Hash ) or obj . kind_of? ( Array ) raise JSON :: ParserError , "Top level JSON object must be a Hash or Array. (actual: #{obj.class})" end if opts [ :create_additions ] . nil? || opts [ :create_additions ] map_to_rb_obj ( obj ) else obj end end
Just call the JSON gem's parse method with a modified :max_nesting field
Just call the JSON gem ' s parse method with a modified : max_nesting field
# JSON gem requires top level object to be a Hash or Array (otherwise # you get the "must contain two octets" error). Yajl doesn't impose the # same limitation. For compatibility, we re-impose this condition. # The old default in the json gem (which we are mimicing because we # sadly rely on this misfeature) is to "create additions" i.e., convert # JSON objects into ruby objects. Explicit :create_additions => false # is required to turn it off.
source
opts