Bug 58912 - Json.Net not working via Live Player
Summary: Json.Net not working via Live Player
Alias: None
Product: Live Player
Classification: Xamarin
Component: Mobile App ()
Version: 1.0.439
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: James Montemagno [MSFT]
Depends on:
Reported: 2017-08-20 16:57 UTC by Martin Jørgensen
Modified: 2017-10-02 11:01 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Crash on Android & iOS null deserialization (281.86 KB, application/x-zip-compressed)
2017-08-25 17:40 UTC, James Montemagno [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Martin Jørgensen 2017-08-20 16:57:33 UTC
Json.Net not working in Live Player:
Android (Live Player 1.0.502) crashes app without any exceptions.
iOS (Live Player 1.0.439) deserializing IEnumerable returns null.

I have tested it in an app with shared code and another app without shared code.

When I build and deploy the code to a real Android device, it works.

Tested using the following code:

public class TypeA
  public int A;
  public string B;

  var in1 = "{\"A\":1,\"B\":\"Test1\"}";
  TypeA out1 = JsonConvert.DeserializeObject<TypeA>(in1);

  var in2 = "[{\"A\":1,\"B\":\"Test1\"},{\"A\":2,\"B\":\"Test2\"},{\"A\":3,\"B\":\"Test3\"}]";
  IEnumerable<TypeA> out2 = JsonConvert.DeserializeObject<IEnumerable<TypeA>>(in2);
catch (Exception ex)
Comment 1 James Montemagno [MSFT] 2017-08-25 17:40:33 UTC
I have verified the crash on Android on both Deserialize Object calls.

iOS Successfully executes: 
  TypeA out1 = JsonConvert.DeserializeObject<TypeA>(in1);

However IEnumerable deserialization does return null, which is a current known limitation of the reflection it uses.

I have added a small sample project as well to click the button and see it.
Comment 2 James Montemagno [MSFT] 2017-08-25 17:40:54 UTC
Created attachment 24424 [details]
Crash on Android & iOS null deserialization
Comment 3 Martin Jørgensen 2017-08-25 18:52:19 UTC
Thank you for confirming, that it is still an issue.

In V1.0.402 the following fix was announced: "Increase NuGet Support: Sqlite-net & Json.NET". I just hoped, that is was the case.

My App requires access to a list of json objects from a web service, so it seems like I will have to develop without using the Live Player - for now.

But I really, really like the idea of Live Player.

It is going to be great!
Comment 4 James Montemagno [MSFT] 2017-08-31 20:15:31 UTC
I would recommend developing with mock data with the Live Player. While it totally can and should be able to do this, the best approach for design type tools like the Live Player is some mock data. It will also speed up your process of using Live Run Current View.