parsing json document

  • Thread starter vahag vardanyan
  • Start date
V

vahag vardanyan

Hi))

am just begening programming with ruby))
but there is a problem with parsing json document
for example I type

require 'json'
JSON.parse '[{"name": "mike"}]'

and there is eror

`require': no such file to load -- json (LoadError).

I am not sudo in server, so I can't install any features.

So how I can parse Json document in Ruby???


sorru for bad English))))
 
K

Karuppasamy M

[Note: parts of this message were removed to make it a legal post.]

It's a common problem for beginners. :) You just include the 'rubygems' at
beginning in you file. Then continue your json parsing work. All the best.

irb(main):001:0> require 'json'
LoadError: no such file to load -- json
from (irb):1:in `require'
from (irb):1

// solution

irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'json'
=> true
 
A

Anurag Priyam

Thanks!)) it's works on my computer))
but on server the same problem with rubygems

Maybe you don't have json gem installed there. Use the gem command to find.

$ gem list json

If you don't have root permissions, you can set Rubygems to install
gems to your home directory. See manual. Or, use RVM on your server -
you can install RVM for a particular user (in this case for yourself)
or system wide.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top