Ruby处理xml、json等数据格式

ActiveSupport::JSON
decode(json) 
Converts a JSON string into a Ruby object. 

[ hide source ]

    # File vendor/rails/activesupport/lib/active_support/json/decoding.rb, line 11
11:       def decode(json)
12:         YAML.load(convert_json_to_yaml(json))
13:       rescue ArgumentError => e
14:         raise ParseError, "Invalid JSON string"
15:       end

encode(value, options = {}) 
Converts a Ruby object into a JSON string. 

[ hide source ]

    # File vendor/rails/activesupport/lib/active_support/json/encoding.rb, line 19
19:       def encode(value, options = {})
20:         raise_on_circular_reference(value) do
21:           value.send(:to_json, options)
22:         end
23:       end

你可能感兴趣的:(json,xml,Ruby,Rails)