Live data from Hacker News

The pain of JSON API testing

jeffkreeftmeijer.com

1–5 of 5 posts

Re: The pain of JSON API testing

#2
I'm not really sure where the idea that JSON APIs are hard to test came from?

They're actually really simple to test because the returned data is in a machine-readable format - JSON. Simply parse the JSON into a data structure that your language understands (hash, array?), and make assertions about the content. The end.

Re: The pain of JSON API testing

#3

I'm not really sure where the idea that JSON APIs are hard to test came from? They're actually really simple to test because the returned data is in a machine-readable format - JSON. Simply parse the JSON into a data structure that your language understands (hash, array?), and make assertions about the content. The end.

I recommend using Hashie::Mash[1] and turn all those hashes into objects, just like those you get when you parse the json in Javascript. This is how ruby's twitter[2] client handles json data.

[1] https://github.com/intridea/hashie

[2] http://twitter.rubyforge.org/

Re: The pain of JSON API testing

#4

I'm not really sure where the idea that JSON APIs are hard to test came from? They're actually really simple to test because the returned data is in a machine-readable format - JSON. Simply parse the JSON into a data structure that your language understands (hash, array?), and make assertions about the content. The end.

I recommend using Hashie::Mash[1] and turn all those hashes into objects, just like those you get when you parse the json in Javascript. This is how ruby's twitter[2] client handles json data. [1] https://github.com/intridea/hashie [2] http://twitter.rubyforge.org/

Good idea, Daniel. Hashr is a tip too: https://github.com/svenfuchs/hashr :)

Re: The pain of JSON API testing

#5

I'm not really sure where the idea that JSON APIs are hard to test came from? They're actually really simple to test because the returned data is in a machine-readable format - JSON. Simply parse the JSON into a data structure that your language understands (hash, array?), and make assertions about the content. The end.

I recommend using Hashie::Mash[1] and turn all those hashes into objects, just like those you get when you parse the json in Javascript. This is how ruby's twitter[2] client handles json data. [1] https://github.com/intridea/hashie [2] http://twitter.rubyforge.org/

[deleted]