本文介绍了如何从JSON数据中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[{"id":7,"message":"This is another test message","taker_id":"131","giver_id":"102","status":"0","stamp":"2016-08-11"}]
那是我的回应.我尝试获取一个基准.我已经尝试过data.id
,但是它失败并返回undefined
.
That's my response. I try to get a datum. I have tried data.id
but it fails and returns undefined
.
推荐答案
我假设您正在使用JSON字符串,因此首先必须将字符串解析为和JSON对象.否则,您将无法访问任何属性.
As I assume that you are working with a JSON string, you first have to parse the string into and JSON object. Else you couldn't reach any of the properties.
parsedData = JSON.parse(data);
然后您可以获取财产:
parsedData[0].id
这篇关于如何从JSON数据中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!