Class String
In: lib/json.rb
Parent: Object
StringScanner Parser JSONTreeView MainWindow Gtk::TreeView OptionsMenu EditMenu PopUpMenu FileMenu Gtk::Window Enumerable TreeIter Gtk State Integer FalseClass Array Hash Class Float NilClass TrueClass String lib/json.rb lib/json/editor.rb MenuExtension lib/json/editor.rb Gtk Editor JSON Kernel TopLevel

Methods

Public Class methods

Raw Strings are JSON Objects (the raw bytes are stored in an array for the key "raw"). The Ruby String can be created by this class method.

[Source]

     # File lib/json.rb, line 587
587:   def self.json_create(o)
588:     o['raw'].pack('C*')
589:   end

Public Instance methods

This string should be encoded with UTF-8 (if JSON unicode support is enabled). A call to this method returns a JSON string encoded with UTF16 big endian characters as \u????. If JSON.support_unicode? is false only control characters are encoded this way, all 8-bit bytes are just passed through.

[Source]

     # File lib/json.rb, line 581
581:   def to_json(*)
582:     '"' << JSON::utf8_to_json(self) << '"'
583:   end

This method should be used, if you want to convert raw strings to JSON instead of UTF-8 strings, e. g. binary data (and JSON Unicode support is enabled).

[Source]

     # File lib/json.rb, line 603
603:   def to_json_raw(*args)
604:     to_json_raw_object.to_json(*args)
605:   end

This method creates a raw object, that can be nested into other data structures and will be unparsed as a raw string.

[Source]

     # File lib/json.rb, line 593
593:   def to_json_raw_object
594:     {
595:       'json_class'  => self.class.name,
596:       'raw'         => self.unpack('C*'),
597:     }
598:   end

[Validate]