简体   繁体   English

C#JSON Rest响应字符串

[英]C# JSON Rest Response String

C# noob here. C#菜鸟在这里。

I'm doing a simple wcf service RestAPI, so far so good...but my json string response isn't coming out the way i wanted. 我正在做一个简单的wcf服务RestAPI,到目前为止很好...但是我的json字符串响应不是我想要的那样。

Actual response: {"GetInfoResult":{"Name": "John"}} 实际回应: {“ GetInfoResult”:{“ Name”:“ John”}}

Desired response: {"Name": "John"} 期望的响应: {“名称”:“约翰”}

how do I remove GetInfoResult field? 如何删除GetInfoResult字段?

Thanks 谢谢

你应该能够只需设置BodyStyle到WebMessageBodyStyle.BareWebGet注释,默认为WebMessageBodyStyle.Wrapped ,增加了不希望的包装;

[WebGet(BodyStyle = WebMessageBodyStyle.Bare)]

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

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