Sha256: 31b08d4235d90bcb3a33cb651fe1d8f06d5c1e8a023c2b36073dde6284c0f66e

Contents?: true

Size: 703 Bytes

Versions: 16

Compression:

Stored size: 703 Bytes

Contents

# Carefully monkey-patch ActiveSupport's JSON encoder, so it *also* does what we need
class ActiveSupport::JSON::Encoding::JSONGemEncoder
  private

  def jsonify(value)
    case value
    when Netzke::Core::JsonLiteral
      value
    when String
      EscapedString.new(value)
    when Numeric, NilClass, TrueClass, FalseClass
      value
    when Hash
      Hash[value.map { |k, v| [jsonify(k), jsonify(v)] }]
    when Array
      value.map { |v| jsonify(v) }
    else
      jsonify value.as_json
    end
  end
end

class Netzke::Core::JsonLiteral < String
  def as_json(options = nil) self end #:nodoc:
  def to_json(options = nil) self end #:nodoc:
  def encode_json(encoder) self end #:nodoc:
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
netzke-core-6.5.0.0 lib/netzke/core/json_literal.rb
netzke-core-6.5.0.0.rc2 lib/netzke/core/json_literal.rb
netzke-core-6.5.0.0.rc1 lib/netzke/core/json_literal.rb
netzke-core-1.0.1.0 lib/netzke/core/json_literal.rb
netzke-core-1.0.0.0 lib/netzke/core/json_literal.rb
netzke-core-1.0.0.0.pre4 lib/netzke/core/json_literal.rb
netzke-core-1.0.0.0.pre3 lib/netzke/core/json_literal.rb
netzke-core-1.0.0.0.pre2 lib/netzke/core/json_literal.rb
netzke-core-1.0.0.0.pre lib/netzke/core/json_literal.rb
netzke-core-0.12.3 lib/netzke/core/json_literal.rb
netzke-core-0.12.2 lib/netzke/core/json_literal.rb
netzke-core-0.12.1 lib/netzke/core/json_literal.rb
netzke-core-0.12.0 lib/netzke/core/json_literal.rb
netzke-core-0.12.0.rc1 lib/netzke/core/json_literal.rb
netzke-core-0.12.0.beta lib/netzke/core/json_literal.rb
netzke-core-0.11.0 lib/netzke/core/json_literal.rb