Issue 47 in jayrock: Cannot deserialize List<>

8 views
Skip to first unread message

jay...@googlecode.com

unread,
Dec 6, 2011, 8:37:30 PM12/6/11
to jayrock...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 47 by jhes...@gmail.com: Cannot deserialize List<>
http://code.google.com/p/jayrock/issues/detail?id=47

When trying to deserialize list, an exception is thrown.

bool isGenericList = Reflector.IsConstructionOfGenericTypeDefinition(type,
typeof(IList<>));

returns false for List<> but can be fixed with

bool isGenericList = Reflector.IsConstructionOfGenericTypeDefinition(type,
typeof(IList<>)) || Reflector.IsConstructionOfGenericTypeDefinition(type,
typeof(List<>));


jay...@googlecode.com

unread,
Dec 6, 2011, 8:41:33 PM12/6/11
to jayrock...@googlegroups.com

Comment #1 on issue 47 by jhes...@gmail.com: Cannot deserialize List<>
http://code.google.com/p/jayrock/issues/detail?id=47

Line can be found in ImportContext.FindCompatibleImporter(Type t)

jay...@googlecode.com

unread,
Dec 7, 2011, 3:13:57 AM12/7/11
to jayrock...@googlegroups.com
Updates:
Status: WontFix
Owner: aziz...@gmail.com
Labels: Component-JSON

Comment #2 on issue 47 by aziz...@gmail.com: Cannot deserialize List<>
http://code.google.com/p/jayrock/issues/detail?id=47

This is by-design. You need to import as IList<T>, not List<T>. List<T> is
a specific and concrete implementation of IList<T> that is meant for
internal use by your code but not mean to be exposed in a public member.

The following will fail:
JsonConvert.Import<List<int>>("[1,2,3]")

The following two, however, will succeed:
JsonConvert.Import<IList<int>>("[1,2,3]")
JsonConvert.Import<ICollection<int>>("[1,2,3]")


Reply all
Reply to author
Forward
0 new messages