Convert JSON data into String

Posted by san6086 on Stack Overflow See other posts from Stack Overflow or by san6086
Published on 2013-10-18T03:37:52Z Indexed on 2013/10/18 3:54 UTC
Read the original article Hit count: 109

Filed under:
|

Hi I am converting JSON data into String. Please find the JSON data below. I am facing an issue where in the system is unable to convert NULL values into string. Therefore, I am getting the following error: can't convert nil into String (TypeError)

JSON DATA:

{"success":true,"message":null,"data":null}

Code Used:

c = Curl::Easy.new(Configuration.fetch("<URL where we can find the above JSON DATA and nothing else>"))
#    c.follow_location = true
#    c.http_auth_types = :basic
#    c.username = Configuration.fetch('auth_user', false)
#    c.password = Configuration.fetch('auth_pass', false)
#    c.headers["User-Agent"] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17'
#    c.perform
     result=JSON.parse(c)
     puts result["Success"]

Please help.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about JSON