A JSON text must at least contain two octets
I received this error, and I couldn't find any reasonable answer to this question, so I thought I'd write a summary of the problem. If you run this snippet in irb: JSON.parse( nil ) You'll see the following error: TypeError: can't convert nil into String I was kind of expecting the function to return nil , and not a TypeError . If you convert all input using to_s , then you'll see the octet error: JSON::ParserError: A JSON text must at least contain two octets! That's just fine and well. If you don't know what an octet is, read this post for a summary and solution: What is a JSON octet and why