我尝试通过给出它的邮政编码来获取地址,并使用getaddress.io网站api和php,它给出了如下给出的JSON结果集,问题是在php变量 $ file 中的结果集。现在我必须将JSON结果转换为jquery数组。
{
"Latitude":-0.020223,
"Longitude":51.504859,
"Addresses":[
"Abbey Offices Ltd, 1 Canada Square, LONDON",
"B B V A, 1 Canada Square, LONDON",
"B P R Interiors Ltd, 1 Canada Square, LONDON",
"Citihub Ltd, 1 Canada Square, LONDON",
"Coutts & Co, 1 Canada Square, LONDON",
"Diligence Ltd, 1 Canada Square, LONDON",
"Doctors of the World UK, 1 Canada Square, LONDON",
"Doyle Clayton, 1 Canada Square, LONDON",
]
}
我想要的输出作为jquery数组的值是,
var output= [
"Abbey Offices Ltd, 1 Canada Square, LONDON",
"B B V A, 1 Canada Square, LONDON",
"B P R Interiors Ltd, 1 Canada Square, LONDON",
"Citihub Ltd, 1 Canada Square, LONDON",
"Coutts & Co, 1 Canada Square, LONDON",
"Diligence Ltd, 1 Canada Square, LONDON",
"Doctors of the World UK, 1 Canada Square, LONDON",
"Doyle Clayton, 1 Canada Square, LONDON",
];
请帮我解决这个问题。 提前致谢
答案 0 :(得分:1)
Per @Darren上述评论:
var data = {
"Latitude":-0.020223,
"Longitude":51.504859,
"Addresses":[
"Abbey Offices Ltd, 1 Canada Square, LONDON",
"B B V A, 1 Canada Square, LONDON",
"B P R Interiors Ltd, 1 Canada Square, LONDON",
"Citihub Ltd, 1 Canada Square, LONDON",
"Coutts & Co, 1 Canada Square, LONDON",
"Diligence Ltd, 1 Canada Square, LONDON",
"Doctors of the World UK, 1 Canada Square, LONDON",
"Doyle Clayton, 1 Canada Square, LONDON",
]
};
var output = data.Addresses;
alert(output);