Parsing json document

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))))

It’s a common problem for beginners. :slight_smile: 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

Thanks!)) it’s works on my computer))

but on server the same problem with rubygems

no such file to load – rubygems((

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs