struct2json
Variables to JSON-text
Installation
-
Add the dependency to your
shard.yml:dependencies: struct2json: github: LightningDAISY/struct2json -
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
- Fork it (https://github.com/lightningdaisy/struct2json/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- lightningdaisy - creator and maintainer