This project has moved and is read-only. For the latest updates, please go here.

int indexed dictionary not working for lists

Aug 19, 2010 at 7:01 AM


I am using your library to interop some data between differnt technologies (in this case PHP - .NET).

I have a int indexed list of data which I serialize PHP side. I was resolving deserializing it with a Dictionary<int, string> in .NET which worked pretty good. However as soon as as my data is 0-indexed and and all keys are in a subsequent order, PHP starts to serialize the data as an JSON array instead of an JSON object.

From there on, I receive an exception in .NET because it can not be deserialized into my object structure. It is working when I use List<string>, however my data is not always 0-indexed.

So my question is, whether you could add this in a future version, that lists can be deserialized into Dictionaries which have some of the default datatypes as index (i.e. string, int, float and some others).

That would help - thanks,


Aug 19, 2010 at 12:17 PM
Edited Aug 19, 2010 at 10:41 PM

I'd rather it was explicit and threw an error. Use LINQ to JSON or a JsonReader to test what the root type it is and then read or deserialize as appropriate.