I'm running in to an issue with Realm and the inability to use basic lists in an object scheme for SomeObject : RealmObject. I'm parsing JSON objects from the web directly in to my Realm objects. It's not mapping like it should for the array parts, in this json data particularly the "entryCharts" data. Here is the JSON from the web. Take a look at the entryCharts array.
{
"id": 20,
"tradeType": "Buy",
"title": "Enter: at market (1,144p)",
"keyPoints": "<ul><li><strong>Enter:</strong> at market (1,144p)</li><li><strong>Stop:</strong> 1107p</li></ul>",
"productId": 2,
"showAsFeatured": false,
"entrySummary": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Semper in malesuada id, varius sit amet lectus. </p>\n",
"entryCharts": [
{
"data": "https://www.somesite.co.uk/somepic.png"
}
],
"entryDate": "2016-06-22T11:32:53.22",
"exitSummary": "",
"takeProfitsDate": null,
"stopHitDate": null,
"createDateUtc": "2016-06-22T11:34:30.04",
"status": "Live"
},
Here's my RealmObject
public class Report : RealmObject
{
[ObjectId]
public int Id { get; set; }
public string TradeType { get; set; }
public string Title { get; set; }
public string KeyPoints { get; set; }
public int ProductId { get; set; }
public bool ShowAsFeatured { get; set; }
public string EntrySummary { get; set; }
public RealmList<EntryChart> EntryCharts { get; }
public string EntryDate { get; set; }
public string ExitSummary { get; set; }
public string TakeProfitsDate { get; set; }
public string StopHitDate { get; set; }
public string CreateDateUtc { get; set; }
public string Status { get; set; }
public Product Product { get; set; }
}
public class EntryChart : RealmObject
{
public string data { get; set; }
}
Based on how your supposed to make arrays of basic types such as string as nested objects this looks like it should work to me but it's not parsing correctly. My only guess is that because RealmList doesn't have a setter it can't make an instance of the RealmList object inside the JSON parser.