int indexed dictionary not working for lists

Aug 19, 2010 at 6:01 AM

Hi,

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,

Philipp

Coordinator
Aug 19, 2010 at 11:17 AM
Edited Aug 19, 2010 at 9: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.