Hello,
I wrote this post a few days ago and I would like to hear your feedback.
Thank you.
Hello,
I wrote this post a few days ago and I would like to hear your feedback.
Thank you.
I like it, I think it would be helpful for beginners. There are lots of
different kinds of API though, it wasn't clear to me until I read a bit
that you were talking about web (or more exactly, REST
<https://en.wikipedia.org/wiki/Representational_state_transfer>\) APIs.
I think most people accessing parsed JSON would use the operator, such
as json['value']['joke'] in your example, but maybe fetch is easier to read
at first. The 'hashie' gem is pretty cool too:
require 'hashie'
mash = Hashie::Mash.new(json)
mash.value.joke
The first result I got when I ran your example was "Chuck Norris describes
human beings as "a sociable holder for blood and guts"." It could
be a good chance to teach people about different kinds of character
escaping that they might encounter.
require 'cgi'
CGI.unescapeHTML mash.value.joke
=> Chuck Norris describes human beings as "a sociable holder for blood and
guts".
I like that your article is short with nice clear code examples. If you
were to do a short series like this covering more central concepts (off the
top of my head; different request verbs, posting data, wrapping
rest-client/json/hashie together in a reusable function), I think it would
be a good resource for people making a start on this stuff.
Nice work ![]()
Doug
On Mon, 12 Oct 2015 at 19:12 jesus <matugm@gmail.com> wrote:
Hello,
I wrote this post a few days ago and I would like to hear your feedback.Working with APIs - Black Bytes
Thank you.