Class: Strada::Adapter::JSON
- Inherits:
-
Object
- Object
- Strada::Adapter::JSON
- Defined in:
- lib/strada/adapter/json.rb
Class Method Summary collapse
-
.from(json) ⇒ Object
将 JSON 转换为 RUBY 数据结构.
-
.to(hash) ⇒ Object
将 RUBY(HASH) 数据结构转换为 JSON.
Class Method Details
.from(json) ⇒ Object
将 JSON 转换为 RUBY 数据结构
22 23 24 25 |
# File 'lib/strada/adapter/json.rb', line 22 def from(json) require "json" ::JSON.load json end |
.to(hash) ⇒ Object
将 RUBY(HASH) 数据结构转换为 JSON
17 18 19 20 |
# File 'lib/strada/adapter/json.rb', line 17 def to(hash) require "json" ::JSON.pretty_generate hash end |