1

Closed

De-serialization issue...

description

Dictionary<int,byte[]> KeysValues=new Dictionary<int,byte[]>();

//Filling...

//Serializing

fastJSON.JSONParameters par = new fastJSON.JSONParameters()
        {
            UseExtensions = false
        };


        string ser = fastJSON.JSON.Instance.ToJSON(KeysValues, par);
//Result (shortend)
[{"k":0,"v":"eyJOYW1lIjoiZHNmIHNkIiwiWHAiOjB9"},{"k":1,"v":"eyJOYW1lIjoiZHNmIHNkIiwiWHAiOjF9"},{"k":2,"v":"eyJOYW1lIjoiZHNmIHNkIiwiWHAiOjJ9"},{"k":3,"v":"eyJOYW1lIjoiZHNmIHNkIiwiWHAiOjN9"},
....etc

//De-serializing
var d = fastJSON.JSON.Instance.ToObject <Dictionary<int, byte[]>>(ser);

//Error here
JSON.cs -> private object ChangeType(object value, Type conversionType)
Invalid Cast Exception "System.String" to "System.Byte[]"

//The same here
//ok
object o = fastJSON.JSON.Instance.Parse(ser);
//error in cast
Dictionary<int,byte[]> _d = (Dictionary<int,byte[]>)o;
Closed Jul 15, 2016 at 11:04 AM by MGholam
Fixed in 2.1.17

comments