The JSON object I’m parsing is at http://api.4chan.org/3/catalog.json
Here is my Ruby code:
['open-uri','nokogiri','json'].each{|g| require g}
json_test = File.open('json_test.JSON','r').read
board_cat_body = Nokogiri::HTML(open('http://api.4chan.org/3/catalog.json'))
puts JSON.parse(board_cat_body)
Result (it’s very long so I took a part of it out):
C:/Ruby193/lib/ruby/1.9.1/json/common.rb:148:in `parse': 387: unexpected token at '{"no":248019,"sticky":1,"closed":1,"now":"12\/19....
However, if I copy and paste the contents of http://api.4chan.org/3/catalog.json into a local JSON file and parse from that local JSON file, there is no problem.
Does anyone know what I’m doing wrong?
Remove the Nokogiri call. JSON isn’t HTML.