Created
June 5, 2014 12:47
-
-
Save anonymous/767a976fa54761af4400 to your computer and use it in GitHub Desktop.
rubyのシンボルを含むデータ構造をJSONに変換するとシンボルがただの文字列になる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"net": { | |
"hostname": "dqneo.example.com" | |
}, | |
"users": [ | |
{ | |
"name": "dqneo", | |
"password": "himitsu" | |
} | |
], | |
"tz": "Asia/Tokyo" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
data = { | |
:net => { | |
:hostname => "dqneo.example.com" | |
}, | |
:users => [ | |
{ :name => 'dqneo', :password => 'himitsu' }, | |
], | |
:tz => "Asia/Tokyo", | |
} | |
puts JSON.pretty_generate(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment