Currently working on a Xamarin project, however facing an issue where object being serialized returns {}
. May I have some advice on this?
Here's my entity class
public class TodoItem
{
[JsonProperty]
public string ID { get; set; }
[JsonProperty]
public string Name { get; set; }
[JsonProperty]
public string Notes { get; set; }
[JsonProperty]
public bool Done { get; set; }
}
The code where I serialize my object
public async Task SaveTodoItemAsync(TodoItem item, bool isNewItem = false)
{
//RestUrl = refer to constants.cs
var uri = new Uri(string.Format(Constants.RestUrl, string.Empty));
try
{
var json = JsonConvert.SerializeObject(item);
var content = new StringContent(json, Encoding.UTF8,
"application/json");
...
}
}
Also, I have noticed when I try to insert data, they all lies in non-public members
. Could that been the cause?