Please Help,
Hi can anybody show me some simple code which shows how using json in
Rails application.
Thanks,
Lekha
Please Help,
Hi can anybody show me some simple code which shows how using json in
Rails application.
Thanks,
Lekha
lekha p. wrote in post #1106474:
Please Help,
Hi can anybody show me some simple code which shows how using json in
Rails application.
Example 1: Rails bult-in JSON support:
For the code look at app/controllers/users_controller.rb
Example 2: JSON from Array
$ rails console
my_arr = %w{a list of some words in an array}
puts my_arr.to_json
Example 3: JSON from Hash
$ rails console
my_hash = {first: “Hello World”, second: 10, third: Time.now}
puts my_hash.to_json
Example 4: RABL
For more sophisticated JSON needs take a look at examples in the RABL
gem:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs