I'm trying to return a list of key/value pairs as JSON from a web service but getting a serialization error with Hashtable.
I've used this in other projects and it was working with returning a Hashtable yesterday, however, it would seem something has changed which causes an error to be thrown:
The type System.Col开发者_如何学Clections.Hashtable is not supported because it implements IDictionary.
I've worked around this by using List>, but I don't see why this was previously working and now is not.
My method signature is:
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public List<KeyValuePair<string, object>> FindPosts(string type, string searchText, int offset) {
Internal Json serializer is perfectly capable of serializing/deserializing hashtable where Xml serializer is not so you're probably using Xml serializer somewhere in your code without noticing it. Look through your code to make sure that all serializations use Json.
精彩评论