简体   繁体   English

如何将JSON数据(在PHP变量中)隐藏到Jquery数组中?

[英]How to covert JSON data(in PHP variable) into Jquery array?



I tried to get addresses by giving the postcode of it and used getaddress.io site api with php and it gave the JSON result set like given below and the issue is the result set in a php variable $file . 我试图通过提供它的邮政编码来获取地址,并将getaddress.io网站api与php一起使用,它给出了如下所示的JSON结果集,而问题在于php变量$ file中的结果集。 now i have to covert JSON result into jquery array . 现在我必须将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",
  ]
}    

Output i wanted as a jquery array values is, 我想要作为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", ];

Please help me on this. 请帮我。 Thanks in advance 提前致谢

Per @Darren comment above: 每个@达伦以上评论:

 var data = { "Latitude":-0.020223, "Longitude":51.504859, "Addresses":[ "Abbey Offices Ltd, 1 Canada Square, LONDON", "BBVA, 1 Canada Square, LONDON", "BPR 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); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM