A
A
Anton2016-05-20 19:44:54
Ruby on Rails
Anton, 2016-05-20 19:44:54

How to parse "impure" JSON?

In general, there is a link. According to her JSON, packed in html->body->pre. I have no idea why the API is given that way.
Question: how to parse it?
At this point, nothing (blank) is passed to JSON.parse

response = Net::HTTP.get(uri)
JSON.parse(response)

What is causing the error:
A JSON text must at least contain two octets!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#algooptimize #bottize, 2016-05-20
@hummingbird

Fully show the text, judging by the error, the impression is that the response does not even have two bytes.

R
Roman Mirilaczvili, 2016-05-20
@2ord

According to her JSON, packed in html->body->pre.

h = JSON.parse(response)
p h.keys

The given resource has keys ["rgDescriptions", "rgInventory", "more_start", "success", "rgCurrency", "more"], but no key named "html". Read the Steam documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question