Sha256: 9e7c9d5eda278739a726fb12da802db41bcebd3209789b8acfe17dd9decc48c9
Contents?: true
Size: 709 Bytes
Versions: 12
Compression:
Stored size: 709 Bytes
Contents
class String # 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. def self.json_create(o) o['raw'].pack('C*') end # This method creates a raw object, that can be nested into other data # structures and will be unparsed as a raw string. def to_json_raw_object { 'json_class' => self.class.name, 'raw' => self.unpack('C*'), } 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). def to_json_raw(*args) to_json_raw_object.to_json(*args) end end
Version data entries
12 entries across 12 versions & 1 rubygems