Class: JsonbSerializer
- Inherits:
-
Object
- Object
- JsonbSerializer
- Defined in:
- app/serializers/jsonb_serializer.rb
Overview
Serialize JSONB.
Class Method Summary collapse
-
.dump(obj) ⇒ JSON
Dump an object to JSON.
-
.load(json) ⇒ Hash
Load a JSON string as a Hash.
Class Method Details
.dump(obj) ⇒ JSON
Dump an object to JSON.
9 10 11 |
# File 'app/serializers/jsonb_serializer.rb', line 9 def self.dump(obj) obj.to_json end |
.load(json) ⇒ Hash
Load a JSON string as a Hash.
17 18 19 20 |
# File 'app/serializers/jsonb_serializer.rb', line 17 def self.load(json) h = JSON.parse(json) if json.instance_of?(String) HashWithIndifferentAccess.new(h) end |