Unable to import typed list using reflection

42 views
Skip to first unread message

Bruno Tezine

unread,
Jun 12, 2015, 10:52:48 AM6/12/15
to jay...@googlegroups.com
Hi Atif, 
It's amazing how jayrock works! It's excellent! I couldn't find a better solution! 

I'm facing some issues when I try to import to a typed list using reflection ParameterInfo. Let me explain: 

I have a function : static void test(List<ETest> list)
I want to call this function using reflection. For this, I call JsonConvert.Import(type, jsonString);
The problem is that 'type' is a ParameterInfo.ParameterType (for List<ETest>) which seems that Jayrock is not able to import. 

Follow the exception I receive: 
Jayrock.Json.JsonException: Cannot import System.Collections.Generic.List`1[MyProject.ETest] from a JSON Array value.
   em Jayrock.Json.Conversion.Converters.ImporterBase.ThrowNotSupported(JsonTokenClass clazz)
   em Jayrock.Json.Conversion.Converters.ImporterBase.Import(ImportContext context, JsonReader reader)
   em Jayrock.Json.Conversion.ImportContext.Import(Type type, JsonReader reader)
   em MyProject.Helper.UncompressAndDeserialize(String completeFunctionName, ParameterInfo parameter, String txt, Boolean& ok)


How I can solve this? 
Thank you again, 
    Bruno.

Atif Aziz

unread,
Jun 12, 2015, 12:31:15 PM6/12/15
to jay...@googlegroups.com, bte...@gmail.com
Bruno, change your list parameter type from List<ETest> to the generic IList<ETest> interface and it should work.

- Atif

Bruno Tezine

unread,
Jun 12, 2015, 4:36:11 PM6/12/15
to jay...@googlegroups.com, bte...@gmail.com
Thank you Atif! 
You saved my life again! :-) 
Reply all
Reply to author
Forward
0 new messages