Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonizer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonizer

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Code Climate Coverage Status Dependencied

Jsonizer

Module to easily provide json serialization

It was structurally inspired by http://github.com/dkubb/equalizer

Installation

Using Bundler (recommended)

  • Add gem 'jsonizer' to your Gemfile
  • Run bundle install

Using rubygems

  • Run gem install jsonizer

Installing from git

  • Clone the repository using git clone git://github.com/voidus/jsonizer
  • Enter the directory using cd jsonizer
  • Build and install the gem with rake install

Usage

class TransferObject
  include Jsonizer.new :operation_id, :parameter

  attr_reader :operation_id, :parameter
  attr_accessor :calculation_strategy

  def initialize operation_id, parameter, transient = "default transient attribute"
    @operation_id = operation_id
    @parameter = parameter
    @transient_attribute = transient
  end
end

TestTransferObject.new("add", [15, 20], 'transient').to_json nil
  # {"json_class":"TestTransferObject","operation_id":"add","parameter":[15,20]}

JSON.dump(TestTransferObject.new("add", [15, 20], 'transient))
  # {"json_class":"TestTransferObject","operation_id":"add","parameter":[15,20]}

JSON.load(JSON.dump(TestTransferObject.new("add", [15, 20], 'transient))).inspect
  # #<TestTransferObject:0x000000018ae188
  #   @operation_id="add",
  #   @parameter=[15, 20],
  #   @transient_attribute="default transient attribute">

JSON.dump(TestTransferObject.new("nested", TestTransferObject.new("op", "param")))
  # {"json_class":"TestTransferObject",
  #  "operation_id":"nested",
  #  "parameter":
  #     {"json_class":"TestTransferObject",
  #      "operation_id":"op",
  #      "parameter":"param"}}

JSON.load(JSON.dump(TestTransferObject.new("nested", TestTransferObject.new("op", "param"))))
  # <TestTransferObject:0x0000000268d308
  #   @operation_id="nested",
  #   @parameter=#<TestTransferObject:0x0000000268d5b0
  #                @operation_id="op",
  #                @parameter="param",
  #                @transient_attribute="default transient attribute">,
  #   @transient_attribute="default transient attribute">

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your tests and changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 01 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc