[ ] Regression (a behavior that stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Documentation issue or request
Current behavior
Given that the current deserialization happens with Newtonsoft.Json inside IContentsClient.GetAsync(...) of a certain mapped C# class(of a schema) I was wondering what an array of different components whould need to look like in order to be mapped correctly to a C# array. Is there any way to accomplish this?
it depends. If all your components have the same type. It is relatively easy.
e.g.
class Article : Content<ArticleData> {}
class ArticleData
{
[JsonConverter(typeof(InvariantConverter))]
public Section[] Sections { get; set; }
}
class Section
{
public string Title { get; set; }
public string Text { get; set; }
}
or for localized articles
class ArticleData
{
public Dictionary<string, Section> Sections { get; set; }
}
If you can assign multiple components you have several options:
I tried with 3rd option given that I structured with increasing fields number per section type and it did work
Meanwhile if I needed for the 1st or 2nd option, how would that work with Squidex.ClientLibrary? I can’t find any function that does return JToken or JObject or a way to pass in my custom converter.