The method JsonConvert.DeserializeObjects works when the Linking is set to SDK Assemblies Only but when I build the project using Link SDK and User Assemblies option in the Linker Properties, it does not work, it returns null in all the fields of the Deserialized object.
You need to put the [Preserve(AllMembers = true)] attribute on any classes that are dynamically generated. This will prevent them from being stripped out.
You can read more on the iOS linker here.
So lets say you currently have a list of Users you want to deserialize you would say something like.
var user = JsonConvert.DeserializeObject<User>(json);
In your User class you will want to place the attribute over that class.
[Preserve(AllMembers = true)]
public class User{
public string Email { get; set; }
public string FirstName { get; set; }
public string Lastname { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With