Last active
December 24, 2015 06:39
-
-
Save coderek/6758981 to your computer and use it in GitHub Desktop.
jruby -S gem install json-jruby
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
## install json-jruby library | |
# jruby -S gem install json-jruby | |
## create json.rb file which contains code below | |
## generate json.class file | |
# jrubyc json.rb | |
## run | |
# java -cp .:/path/to/jruby-complete-1.7.4.jar json | |
## should see some output | |
require "rubygems" | |
require "json" | |
# de-serializing: | |
source_string = '{"sample": "Hello, world!"}' | |
puts JSON(source_string).inspect | |
# => {"sample"=>"Hello, world!"} | |
# serializing: | |
source_object = ["Just another Ruby Array", {"null value" => nil}] | |
puts JSON(source_object) | |
# => ["Just another Ruby Array",{"null value":null}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment