module SerialBox::Serializers::JSON
JSON
adapter for {SerialBox}. Defines the following methods when included in a class:
-
‘#as_json`
-
‘#to_json`
-
‘.json_create`
This gives the class total ability to work with ‘JSON.parse` and `#to_json`.
Constants
- JSON_CREATE_ID
@private
Public Instance Methods
as_json(*)
click to toggle source
Converts this object into primitives suitable for JSON
serialization.
@return [Hash, Array] A JSON-serializable object.
# File lib/serializers/json.rb, line 29 def as_json(*) hsh = {SerialBox::Serializers::JSON::JSON_CREATE_ID => self.class.name} self.class._serialbox_serializer.serialization_operations.each do |operation| operation.apply self, hsh end return hsh end