Module: Rapidomize::Encoding::Json
- Included in:
- Payload
- Defined in:
- lib/rapidomize/encoding/json.rb
Overview
Encode payload to JSON and build payload from JSON
Instance Method Summary collapse
-
#from_json(str) ⇒ Object
Add to Payload from a JSON string This can also be used to add data from JSON strings.
-
#to_json(*args) ⇒ String
Encode the payload object in JSON.
Instance Method Details
#from_json(str) ⇒ Object
Add to Payload from a JSON string This can also be used to add data from JSON strings
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rapidomize/encoding/json.rb', line 21 def from_json(str) json = JSON.parse(str) if json.is_a? Array json.each do |j| self << Rapidomize::Payload.new.from_hash(j) end else from_hash(json) end self end |
#to_json(*args) ⇒ String
Encode the payload object in JSON
10 11 12 |
# File 'lib/rapidomize/encoding/json.rb', line 10 def to_json(*args) data.to_json(*args) end |