[英]Array of JSON from fetch
After making a fetch request to an api, the response is an array of JSONs, like so: 向api发出提取请求后,响应为JSON数组,如下所示:
[ {"key":"val", "k2":"v2"}, {"k3":"v3", "k4":"v4"} ]
So far I am trying to handle this by doing response => response.text()
到目前为止,我正在尝试通过执行response => response.text()
来处理此问题。
Is there any efficient method to parse this array into separate JSONs, other than tediously parsing it as one big string? 除了繁琐地将其解析为一个大字符串之外,是否有任何有效的方法可以将该数组解析为单独的JSON?
Use the body.json() function 使用body.json()函数
response.json().then(function(data) {
// do something with your data
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.