This file contains hidden or 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
| # JSON Parsing example | |
| require "rubygems" | |
| require "json" | |
| string = '{"desc":{"someKey":"someValue","anotherKey":"value"},"main_item":{"stats":{"a":8,"b":12,"c":10}}}' | |
| parsed = JSON.parse(string) # returns a hash | |
| p parsed["desc"]["someKey"] | |
| p parsed["main_item"]["stats"]["a"] |
This file contains hidden or 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
| I found a good example of how to parse JSON with ruby on stack overflow here => http://stackoverflow.com/a/13625633 | |
| For an example of AWS JSON, I found an example at (http://unix.stackexchange.com/questions/121718/how-to-parse-json-with-shell-scripting-in-linux), but I fixed some errors in the json and have a copy here (https://gist.github.com/Cinderhaze/f122232d15eb700449f0) | |
| I put the above json in a file (ec2s.json) and ran 'gem install json' | |
| I have tried the following in IRB | |
| require 'json' | |
| file = File.open('ec2s.json') | |
| contents = file.read | |
| file.close |
This file contains hidden or 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
| { | |
| "OwnerId": "121456789127", | |
| "ReservationId": "r-48465168", | |
| "Groups": [], | |
| "Instances": [ | |
| { | |
| "Monitoring": { | |
| "State": "disabled" | |
| }, | |
| "PublicDnsName": null, |
This file contains hidden or 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
| PROVISIONED="/some-app-dir/PROVISIONED"; | |
| if [[ -f $PROVISIONED ]]; then | |
| echo "Skipping provisioning"; | |
| exit; | |
| else | |
| echo "Provisioning"; | |
| fi | |
| #...do provisioning things |
This file contains hidden or 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
| Building native extensions. This could take a while... | |
| ERROR: Error installing rails: | |
| ERROR: Failed to build gem native extension. | |
| /usr/bin/ruby1.9.1 extconf.rb | |
| /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError) | |
| from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' | |
| from extconf.rb:1:in `<main>' | |
NewerOlder