Tag: json

Rails 3:如何在JSON请求中返回错误?

当用户向我的API发出JSON / XML请求时,如何返回800,404等错误? 我试过了 error 404, {:error => "ERror".to_json } 没有成功。 此外,我试图把“respond_to”,但它不工作(它重复respond_to并给出错误)。 谢谢

如何在swagger.io中定义枚举?

有没有人能够在swaggger 2.0版的Model选项卡中定义可能的“enum”值? 示例在这里: http : //petstore.swagger.wordnik.com/#!/pet/addPet有一个“状态”属性的枚举选项,但该示例使用swagger的版本1.0(根据JSON对象中定义的swagger版本)。 我试图在版本2.0中实现相同,但没有运气,不知道文件是正确的。 任何暗示呢?

Python JSON解码性能

我在Python 2.6中使用json模块来加载和解码JSON文件。 但是,我目前的performance比预期慢。 我正在使用一个大小为6MB的testing用例, json.loads()需要20秒。 我以为json模块有一些本地代码来加速解码? 如何检查是否正在使用? 作为比较,我下载并安装了python-cjson模块,而cjson.decode()在同一个testing用例中需要1秒。 我宁愿使用Python 2.6提供的JSON模块,以便我的代码的用户不需要安装额外的模块。 (我在Mac OS X上开发,但在Windows XP上得到类似的结果。)

NodeJS HttpGet转换为带有JSON响应的URL

我是新的节点开发,我试图做一个服务器端API调用使用RESTful协议与JSON响应。 我已经阅读了API文档和这个SOpost 。 我试图拉的API跟踪总线并返回JSON输出中的数据。 我很困惑如何使用实际URL中的所有参数和选项进行HTTP GET请求。 API和它的响应甚至可以通过浏览器或使用“curl”命令来访问。 http://developer.cumtd.com/api/v2.2/json/GetStop?key=d99803c970a04223998cabd90a741633&stop_id=it 如何编写Node服务器端代码,向URL中的选项发出GET请求,并解释JSON响应? 提前致谢!

JSON序列化在C#中

我想序列化本地对象到JSON,但MSDN文档总是似乎混淆了我。 我相信我想使用DataContractJsonSerializer,但不完全确定,因为我看到了混合的反应。 我也有人推荐牛顿软件。 有没有人有这方面的经验,可以指出我在正确的方向吗?

在一行中用NewtonSoft生成JSON对象

我正在使用JSON库NewtonSoft生成一个JSONstring: JObject out = JObject.FromObject(new { typ = "photos" }); return out.ToString(); 输出: { "typ": "photos" } 我的问题:是否有可能得到一个单一的行输出如下: {"typ": "photos"}

如何从iOS中的文件parsingJSON?

我正试图parsing来自JSON文件的数据。 我试图把parsing/提取的数据放入一个UIView的标签或在web视图中。 JSON文件如下所示: {"bodytext": "<p>\n Some lines here about some webpage (&ldquo; <em>Site</>&rdquo;) some more lines here. \n </p>\n\n <p>\n some more stuff here </p> } 有堆栈溢出显示如何parsing从Web URL检索JSON的post,但我实际上已经有一个JSON文件,我想parsing。 如何parsing文件中的JSON?

如何在Python中美化JSON?

有人可以build议我怎么可以在Python中或通过命令行美化JSON? 唯一可以做到的基于在线的JSON美化器是: http : //jsonviewer.stack.hu/ 。 但是,我需要从Python中使用它。 这是我的数据集: { "head": {"vars": [ "address" , "description" ,"listprice" ]} , "results": { "bindings": [ { "address" : { "type":"string", "value" : " Dyne Road, London NW6"}, "description" :{ "type":"string", "value" : "6 bed semi detached house"}, "listprice" : { "type":"string", "value" : "1,150,000"} } , { "address" […]

Restlet,CLAP,Ajax和块超时

我们正在使用RESTlet为我们的项目做一个小的REST服务器。 我们在从Applicationinheritance的类中build立了一堆路由: public static void createRestServer(ApplicationContext appCtx, String propertiesPath) throws Exception { // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 8081); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); Context context = component.getContext().createChildContext(); RestServer application = new RestServer(context); application.getContext().getParameters().add("useForwardedForHeader", "true"); application.getContext().getAttributes().put("appCtx", appCtx); application.getContext().getAttributes().put("file", propertiesPath); // Attach the application to the component and start it component.getDefaultHost().attach(application); component.start(); } private RestServer(Context […]

JSON中的.d是什么意思?

我有一个.NET webmethod,我从jQuery调用。 该方法返回一些在DIV元素中显示的HTML标记。 一旦我有我使用的答复 $("#div").html(result.d); 我的问题是,.d做什么? 我不喜欢使用我不完全理解的代码? 我可以使用Eval获得相同的结果吗?