繁体   English   中英

将JSON数据转换为String

[英]Convert JSON data into String

嗨,我正在将JSON数据转换为String。 请在下面找到JSON数据。 我面临系统中无法将NULL值转换为字符串的问题。 因此,我收到以下错误:无法将nil转换为String(TypeError)

JSON数据:

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

使用的代码:

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"]

请帮忙。

尝试

puts result["success"]

您有一个小写的大写字母S。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM