Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Core and Standard Library Ruby Standard Library: Part 2 JSON

Mariah Schmidt
seal-mask
.a{fill-rule:evenodd;}techdegree
Mariah Schmidt
Full Stack JavaScript Techdegree Student 13,692 Points

Require the 'json' library so it can be used

In the video, it looked like all that was needed to work with JSON in Ruby was to "require 'json'". What did I miss?

json.rb
require 'json'
json_string = <<-STR
  { "name": "Treehouse", "location": "Portland, OR" }
STR.json
  { "name": "Treehouse", "location": "Portland, OR" }
STR.json

1 Answer

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

You're requiring the 'json' library correctly. But STR is actually the marker that marks the end of the multi-line string that's being assigned to json_string. STR needs to be all by itself on the line.

I'd recommend re-watching the video one more time to figure out how to call parse correctly. Your solution needs to look something like this:

require 'json'

json_string = <<-STR
  { "name": "Treehouse", "location": "Portland, OR" }
STR

treehouse = # YOUR CODE HERE