0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Adds to ActiveRecord the ability to JSON-serialize certain fields.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

Runtime

 Project Readme

json_serialize

JSON serialization in ActiveRecord

Author Tim Morgan
Version 2.2.2 (May 15, 2013)
License Released under the MIT license.

About

json_serialize gives you the ability to JSON-encode data into ActiveRecord model fields. JSON is a more compact but less robust serialization than YAML. Only hashes, arrays, and primitives can be reliably encoded to database fields; other types may not decode properly or at all.

Installation and Usage

Firstly, add the gem to your Rails project's Gemfile:

gem 'json_serialize'

Then, include into your model the JsonSerialize module, and call the json_serialize method to indicate which fields should be serialized:

class MyModel < ActiveRecord::Base
  include JsonSerialize
  json_serialize :favorites, :preferences
end

More information can be found at the {JsonSerialize::ClassMethods#json_serialize} method documentation.