json asmx和讨厌的d: [英] json asmx and that pesky d:

查看:90
本文介绍了json asmx和讨厌的d:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览了很多帖子,但没有成功确定如何摆脱来自我的asmx Web服务的响应中的讨厌的d,如{"d":{"Response":"OK" ,"Auth-Key":"JKPYZFZU"}}.

I have looked through lots of Posts and have not been successful in determining how to get rid of the pesky d in the response coming from my asmx web service, as in {"d":{"Response":"OK","Auth-Key":"JKPYZFZU"}}.

这是由我的类"public Dictionary UserDevice"通过返回Dictionary对象创建的.

This is being created by my class 'public Dictionary UserDevice' by returning the Dictionary object.

如果该死的东西不会把所有东西都放到d对象中,我会非常高兴!

I would be perfectly happy if the damn thing just wouldn't put it all into the d object!

推荐答案

您可能正在使用某种框架,该框架会自动用d元素包装Web服务json响应.

You are probably using some kind of framework that automatically wraps your web service json responses with the d element.

我知道Microsoft的JSON序列化程序在服务器端添加了d,反序列化JSON字符串的客户端AJAX代码希望它存在. 我认为jQuery也是如此.

I know that microsoft's JSON serializer adds the d on the server side, and the client-side AJAX code that deserializes the JSON string expects it to be there.
I think jQuery works this way too.

您可以在 Rick Strahl的博客

还有一种方法可以让您使用

And there is a way for you to return pure json (without the 'd' element) using the WCF "Raw" programming model.

这篇关于json asmx和讨厌的d:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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