【发布时间】:2023-03-05 17:31:01
【问题描述】:
经过多次测试和搜索,解析JSON后找不到导航方式;这是解析后的结果:
Object {documentation: "https://geocoder.opencagedata.com/api", licenses: Array[2], rate: Object, results: Array[1], status: Object…}
文档 : "https://geocoder.opencagedata.com/api" 许可证 : 数组[2] 速度 : 目的 结果 : 数组[1] 0 : 目的 注释 : 目的 成分 : 目的 建造 : “C” 城市 : “波尔多” 国家 : “法国” 国家代码 : “法国” 县 : “波尔多” 邮政编码 : “33000” 路 : “Quai de Bacalan” 状态 : “阿基坦” 市郊 : “波尔多海事”
例如,我可以使用以下代码获取响应的值:
var locname = response.status.code;
但是在这种情况下有一个int作为Object,像这样:
var locname = response.results.0.formatted;
我有以下错误:
Uncaught SyntaxError: Unexpected number
我尝试转义字符,加上引号等,但找不到任何解决方案。
【问题讨论】:
标签: javascript json object int