json.sf 243 B

1234567891011121314
  1. #!/usr/bin/ruby
  2. var json = require('JSON::PP').new;
  3. # Parse JSON
  4. var data = json.decode('{"blue": [1, 2], "ocean": "water"}');
  5. say data;
  6. # Change JSON
  7. data{:ocean} = Hash.new(water => %w[fishy salty]);
  8. # Encode JSON
  9. say json.encode(data);