class TJSON::DataType::Object
TJSON
objects
Public Instance Methods
decode(obj)
click to toggle source
# File lib/tjson/datatype/object.rb, line 11 def decode(obj) raise TJSON::TypeError, "expected TJSON::Object, got #{obj.class}" unless obj.is_a?(TJSON::Object) # Objects handle their own member conversions obj end
encode(obj)
click to toggle source
# File lib/tjson/datatype/object.rb, line 18 def encode(obj) members = obj.map do |k, v| raise TypeError, "expected String for key, got #{k.class}" unless k.is_a?(::String) || k.is_a?(Symbol) type = TJSON::DataType.identify_type(v) ["#{k}:#{type.tag}", TJSON::DataType.encode(v)] end Hash[members] end
inspect()
click to toggle source
# File lib/tjson/datatype/object.rb, line 28 def inspect "#<#{self.class}>" end
tag()
click to toggle source
# File lib/tjson/datatype/object.rb, line 7 def tag "O" end