开发者

How can i return a dynamic json/xml object in my WCF webservice

开发者 https://www.devze.com 2023-02-05 00:04 出处:网络
I have several webservices working as an API for my database, built in C#, WCF 4, returning json and xml format. Currently they work with specific Typed objects, but i want to be able to return dynami

I have several webservices working as an API for my database, built in C#, WCF 4, returning json and xml format. Currently they work with specific Typed objects, but i want to be able to return dynamic data. Somewhat like what the Youtube API does, you can send in the "fields" variable, and only get the specified datafields back.

I'm thinking i could probably use the Dynamic type for this somehow, but I havn't used it much and have no idea wher开发者_JS百科e to begin. Ideally if someone could point me to a project where this has been implemented i could learn from there, or if someone has an idea on how to implement this.


You can return IDictionary. The JSON serializer will pick it up and serialize correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消