0

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.

2
  • Show us your current attempt that is producing the error. Commented Oct 18, 2013 at 3:38
  • I have edited the issue. Hope you can see the code now. Commented Oct 18, 2013 at 3:42

1 Answer 1

1

Try

puts result["success"]

You have a capital S where you need a lower case one.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply. But my effort failed. I got a new error "can't convert Curl::Easy into String (TypeError)."
You can try to edit your code in an IRB session first. It will tell you after every step, what it makes of what you entered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.