Last active
June 21, 2016 10:09
-
-
Save y13i/4d93b5097f11373f8a04 to your computer and use it in GitHub Desktop.
GoでJSONとYAMLを相互変換するツールを作った ref: http://qiita.com/y13i/items/ee93ea07ecff11990676
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
$ cat example.json | |
{"employees":[ | |
{"firstName":"John", "lastName":"Doe"}, | |
{"firstName":"Anna", "lastName":"Smith"}, | |
{"firstName":"Peter", "lastName":"Jones"} | |
]} | |
$ j2y example.json | |
employees: | |
- firstName: John | |
lastName: Doe | |
- firstName: Anna | |
lastName: Smith | |
- firstName: Peter | |
lastName: Jones |
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
$ j2y -o example.yml example.json | |
$ cat example.yml | |
employees: | |
- firstName: John | |
lastName: Doe | |
- firstName: Anna | |
lastName: Smith | |
- firstName: Peter | |
lastName: Jones |
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
$ j2y -r example.yml | |
{ | |
"employees": [ | |
{ | |
"firstName": "John", | |
"lastName": "Doe" | |
}, | |
{ | |
"firstName": "Anna", | |
"lastName": "Smith" | |
}, | |
{ | |
"firstName": "Peter", | |
"lastName": "Jones" | |
} | |
] | |
} |
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
$ j2y -r -m example.yml | |
{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]} |
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
$ j2y -e '{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}' | |
employees: | |
- firstName: John | |
lastName: Doe | |
- firstName: Anna | |
lastName: Smith | |
- firstName: Peter | |
lastName: Jones |
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
$ echo '{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}' | j2y | |
employees: | |
- firstName: John | |
lastName: Doe | |
- firstName: Anna | |
lastName: Smith | |
- firstName: Peter | |
lastName: Jones |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment