instance method encode_json

Ruby on Rails 3.1.12

Since v3.0.20 Last seen in v3.2.22.5

Available in: v3.0.20 v3.1.12 v3.2.22.5

Signature

encode_json(encoder)

No documentation comment.

Parameters

encoder req
Source
# File activesupport/lib/active_support/json/encoding.rb, line 248
  def encode_json(encoder)
    # values are encoded with use_options = false, because we don't want hash representations from ActiveModel to be
    # processed once again with as_json with options, as this could cause unexpected results (i.e. missing fields);

    # on the other hand, we need to run as_json on the elements, because the model representation may contain fields
    # like Time/Date in their original (not jsonified) form, etc.

    "{#{map { |k,v| "#{encoder.encode(k.to_s)}:#{encoder.encode(v, false)}" } * ','}}"
  end

Defined in activesupport/lib/active_support/json/encoding.rb line 248 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Hash

Type at least 2 characters to search.

↑↓ navigate · open · esc close