有没有办法可以从服务器检索JSON文件 [英] Is there a way I can retrieve the JSON file from server

查看:110
本文介绍了有没有办法可以从服务器检索JSON文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考上面的问题,我想要检索文件的原因是我想知道它的结构,因此我可以使用数据代替复制的脚本.

当前,$.getJSON网址中包含字符串"callback=?".

无论如何,我可以窥视一下还是看到$.getJSON url字符串内的文件中的数据结构如何?

实际上,我遵循下面的演示

https://code.google.com/r/kgraham-flr-map/source/browse/examples/medicare-dynamic-ds.js?spec=svn72fd5de93cf24b0b2baa5d2678d9518741e3d80b&r=72dd5de93cf24b0b2ba4a1c >

有问题的脚本具有$.getJSON('https://storelocator-go-demo.appspot.com/query?callback=?'来解析数据.

当我尝试打开URL时,出现此错误strconv.ParseFloat: parsing "": invalid syntax

我想看看JSON文件的结构,以便可以用自己的数据替换它.

希望这可以清除我的问题.

解决方案

来自注释:

所以您是说我在尝试打开json文件时遇到的错误是由于服务器问题引起的吗?

好吧,它可以为您提供更有用的错误消息.问题是您没有给它提供所需的参数.

如果我去

https://storelocator-go-demo.appspot.com/query?callback=foo

...然后像你​​一样,我得到了那个错误.但是,如果我给它参数(这些是从您提供的示例链接中得出的):

https://storelocator-go-demo.appspot.com/query?callback=foo&lat=-29.292219923932738&lng=137.763512&n=-10.691329506145314&e=167.382652625&s=-47.89311034172016&w=108.14437137499999&audio=&access=&_=1364633286163

我获得了有效的JSONP响应.

Referring to my question above, the reason I want to retrieve the file is that I want to know how it is structured so I can make the script that I copied work using my data instead.

Currently, the $.getJSON url includes the string "callback=?" in it.

So is there anyway, I can peek through or see how the data is structured in the file thats inside the $.getJSON url string?

actually, Im following along a demo below

https://code.google.com/r/kgraham-flr-map/source/browse/examples/medicare-dynamic-ds.js?spec=svn72fd5de93cf24b0b2baa5d2678d9518741e3d80b&r=72fd5de93cf24b0b2baa5d2678d9518741e3d80b

Tthe script in question has the $.getJSON('https://storelocator-go-demo.appspot.com/query?callback=?' to parse the data.

When I tried opening the url, I get this error strconv.ParseFloat: parsing "": invalid syntax

I want to see how the JSON file is structured so I can replace it with my own data instead.

Hope this clears my question.

解决方案

From the comments:

so you mean the error that I got when trying to open the json file is due to a server problem?

Well, it could give you a more useful error message. The problem is that you're not giving it the arguments it requires.

If I go to:

https://storelocator-go-demo.appspot.com/query?callback=foo

...then like you, I get that error. But if I give it arguments (these are cribbed from the examples link you gave):

https://storelocator-go-demo.appspot.com/query?callback=foo&lat=-29.292219923932738&lng=137.763512&n=-10.691329506145314&e=167.382652625&s=-47.89311034172016&w=108.14437137499999&audio=&access=&_=1364633286163

I get back a valid JSONP response.

这篇关于有没有办法可以从服务器检索JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆