开发者

In WCF, how do I convert a Datatable to a format that will output in JSON store format without classes

开发者 https://www.devze.com 2023-01-27 09:50 出处:网络
So here\'s the problem - I have a DataTable I want WCF (.NET 3.5) to send out in a JSON store format commonly used in ExtJS, etc - b开发者_如何学Pythonasically \"Rows[{\"Field1\":value,\"Field2\":valu

So here's the problem - I have a DataTable I want WCF (.NET 3.5) to send out in a JSON store format commonly used in ExtJS, etc - b开发者_如何学Pythonasically "Rows[{"Field1":value,"Field2":value},{...}]" but I cannot find the right structure to feed back to the Operation contract to send it out in this format.

So any ideas, or any further info needed.

Thanks, in advance!


AndyPC, unfortunately, you're out of luck.

If you're dealing with an object whose type is an IXmlSerializable, the WCF JSON serializer delegates to IXmlSerializable methods first, gets the serialized XML out of them, wraps the XML in a JSON string, and just passes that on. This is one of the major weaknesses of the WCF JSON model in .NET 3.5. I think the entity framework (WCF Data Services) technologies try to handle this more elegantly, but not sure. I'd recommend manually using the JSON serializer and crafting up a string or a manual serialization mechanism that does what you want...

0

精彩评论

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

关注公众号