需要帮助解析 JSON
response = Typhoeus::Request.get(API_SERVER_ADDRESS + "users/" + params[:id] +"/friends" + API_OAUTH_TOKEN)
@parsed_json = ActiveSupport::JSON.decode(response.body)
@parsed_json['get.friendlist']["friendslist"].each do |first_name, last_name|
p first_name
end
Json 格式:-
{
-get.friendlist: {
-friendslist: [
-{
id: "6"
first_name: "Jeyaprabhu"
last_name: "Palanichamy"
im_screen_name: ""
email: "[email protected]"
password: "c4cce19cf6453c10754339a15cf9265d"
mobile: ""
date_of_birth: ""
gender: "male"
}
-{
id: "72"
first_name: "Saravanan"
last_name: "R"
im_screen_name: "Saravanan R"
email: "[email protected]"
password: "7cc2f5546b199421184a287bb75c406d"
mobile: ""
date_of_birth: "9/9/1985"
gender: "male"
}
]
}
}
它不打印first_name 的值..
response = Typhoeus::Request.get(API_SERVER_ADDRESS + "users/" + params[:id] +"/friends" + API_OAUTH_TOKEN)
@parsed_json = ActiveSupport::JSON.decode(response.body)
@parsed_json['get.friendlist']["friendslist"].each do |first_name, last_name|
p first_name
end
Json Format:-
{
-get.friendlist: {
-friendslist: [
-{
id: "6"
first_name: "Jeyaprabhu"
last_name: "Palanichamy"
im_screen_name: ""
email: "[email protected]"
password: "c4cce19cf6453c10754339a15cf9265d"
mobile: ""
date_of_birth: ""
gender: "male"
}
-{
id: "72"
first_name: "Saravanan"
last_name: "R"
im_screen_name: "Saravanan R"
email: "[email protected]"
password: "7cc2f5546b199421184a287bb75c406d"
mobile: ""
date_of_birth: "9/9/1985"
gender: "male"
}
]
}
}
Its not printing the value of first_name..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个..
Try this..