Class: JSONx

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ JSONx

Returns a new instance of JSONx.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jsonx.rb', line 13

def initialize(obj)
  
  if obj.is_a?(String) then
    
    if obj.lstrip[0] == '<' then
      jsonx_to_json obj
    else
      json_to_jsonx JSON.parse(obj)
    end
    
  else
    json_to_jsonx obj # transform the hash
  end

end

Instance Attribute Details

#to_jsonObject (readonly)

Returns the value of attribute to_json.



11
12
13
# File 'lib/jsonx.rb', line 11

def to_json
  @to_json
end

#to_sObject (readonly) Also known as: to_jsonx, to_xml

Returns the value of attribute to_s.



11
12
13
# File 'lib/jsonx.rb', line 11

def to_s
  @to_s
end