【发布时间】:2020-03-08 08:17:56
【问题描述】:
我是 react-native 和 JavaScript 的新手。我的 JSON 看起来像这样:
{"AB1281":{"id":"AB1281","score":90,"status":"SUCCESS"},
"CA9412":{"id":"CA9412","score":40,"status":"FAILED"},
"GG1921":{"id":"GG1921","score":80,"status":"SUCCESS"}}
假设我从这段代码中得到这个 JSON:
componentDidMount() {
return fetch(url)
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson,
})
})
.catch((error) => {
console.log(error)
});
};
如您所见,所有键都各不相同(“AB1281”、“CA9412”、“GG1921”)。如何解析这些数据并在列表视图中呈现?
【问题讨论】:
标签: javascript json react-native react-native-android