简体   繁体   中英

C# JSON Rest Response String

C# noob here.

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.

Actual response: {"GetInfoResult":{"Name": "John"}}

Desired response: {"Name": "John"}

how do I remove GetInfoResult field?

Thanks

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

[WebGet(BodyStyle = WebMessageBodyStyle.Bare)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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