123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::JSON::Encoding

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Defined in: activesupport/lib/active_support/json/encoding.rb

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

.escape_html_entities_in_json (rw)

If true, encode >, <, & as escaped unicode sequences (e.g. > as u003e) as a safety measure.

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 212

attr_accessor :escape_html_entities_in_json

.escape_js_separators_in_json (rw)

If true, encode LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) as escaped unicode sequences (‘u2028’ and ‘u2029’). Historically these characters were not valid inside JavaScript strings but that changed in ECMAScript 2019. As such it’s no longer a concern in modern browsers: caniuse.com/mdn-javascript_builtins_json_json_superset.

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 219

attr_accessor :escape_js_separators_in_json

.json_encoder (rw)

Sets the encoder used by Rails to encode Ruby objects into ::ActiveSupport::JSON strings in Object#to_json and ActiveSupport::JSON.encode.

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 227

attr_reader :json_encoder

.json_encoder=(encoder) (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 229

def json_encoder=(encoder)
  @json_encoder = encoder
  @encoder_without_options = encoder.new
  @encoder_without_escape = encoder.new(escape: false)
end

.time_precision (rw)

Sets the precision of encoded time values. Defaults to 3 (equivalent to millisecond precision)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 223

attr_accessor :time_precision

.use_standard_json_time_format (rw)

If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format.

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 208

attr_accessor :use_standard_json_time_format

Class Method Details

.encode_without_escape(value)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 239

def encode_without_escape(value) # :nodoc:
  @encoder_without_escape.encode(value)
end

.encode_without_options(value)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 235

def encode_without_options(value) # :nodoc:
  @encoder_without_options.encode(value)
end