struct2json

Variables to JSON-text

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      struct2json:
        github: LightningDAISY/struct2json
  2. Run shards install

Usage

require "struct2json"

hash = {
  "members" => [
    { "id" => 1, "name" => "山田 => やまだ" },
    { "id" => 2, "name" => "鈴木" },
    { "id" => 3, "name" => "佐藤" },
    { "id" => 4, "name" => nil },
    { "id" => 4.5, "name" => false },
  ],
}

text = hash.to_json
puts text

Result

{"members" : [{"id" : 1, "name" : "山田 => やまだ"}, {"id" : 2, "name" : "鈴木"}, {"id" : 3, "name" : "佐藤"}, {"id" : 4, "name" : null}, {"id" : 4.5, "name" : false}]}

Contributing

  1. Fork it (https://github.com/lightningdaisy/struct2json/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors