Sha256: 840bf9c98f9d042696f77b994c75ba6fcd132054078a46bc9de246258eff5a89

Contents?: true

Size: 545 Bytes

Versions: 6

Compression:

Stored size: 545 Bytes

Contents

require "json"

# +JSON.parse '{"json_class":"MyClass"}'+ should not create object as MyClass
JSON.load_default_options.merge! create_additions: false
JSON::GenericObject.json_creatable = false

[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
  klass.class_eval do
    # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
    # "</" is escaped for convenience use in javascript
    def to_json(options = nil)
      super(options).gsub '</', "<\\/"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nyara-0.1.pre.2 lib/nyara/patches/json.rb
nyara-0.1.pre.1 lib/nyara/patches/json.rb
nyara-0.1.pre.0 lib/nyara/patches/json.rb
nyara-0.0.1.pre.9 lib/nyara/patches/json.rb
nyara-0.0.1.pre.8 lib/nyara/patches/json.rb
nyara-0.0.1.pre.6 lib/nyara/patches/json.rb