Extends modul with the String::Extend module.
# File lib/json/pure/generator.rb, line 433 433: def self.included(modul) 434: modul.extend Extend 435: end
This string should be encoded with UTF-8 A call to this method returns a JSON string encoded with UTF16 big endian characters as u????.
# File lib/json/pure/generator.rb, line 394 394: def to_json(state = nil, *args) 395: state = State.from_state(state) 396: if encoding == ::Encoding::UTF_8 397: string = self 398: else 399: string = encode(::Encoding::UTF_8) 400: end 401: if state.ascii_only? 402: '"' << JSON.utf8_to_json_ascii(string) << '"' 403: else 404: '"' << JSON.utf8_to_json(string) << '"' 405: end 406: end
This string should be encoded with UTF-8 A call to this method returns a JSON string encoded with UTF16 big endian characters as u????.
# File lib/json/pure/generator.rb, line 411 411: def to_json(state = nil, *args) 412: state = State.from_state(state) 413: if state.ascii_only? 414: '"' << JSON.utf8_to_json_ascii(self) << '"' 415: else 416: '"' << JSON.utf8_to_json(self) << '"' 417: end 418: end
This method creates a JSON text from the result of a call to to_json_raw_object of this String.
# File lib/json/pure/generator.rb, line 450 450: def to_json_raw(*args) 451: to_json_raw_object.to_json(*args) 452: end
This method creates a raw object hash, that can be nested into other data structures and will be unparsed as a raw string. This method should be used, if you want to convert raw strings to JSON instead of UTF-8 strings, e. g. binary data.
# File lib/json/pure/generator.rb, line 441 441: def to_json_raw_object 442: { 443: JSON.create_id => self.class.name, 444: 'raw' => self.unpack('C*'), 445: } 446: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.