I’m submitting a…
- [x] Documentation issue or request
Environment
We just discovered Squidex and are trying to test the possibilities of the CMS. As outlined in Allow schemas to have arrays inside arrays, we have created a schema for the home page which isn’t flat but has a nested schema instead.
We are grateful for the NuGet library Squidex.ClientLibrary which saves us the time of writing the underlying API calls ourselves. Unfortunately, the documentation of Squidex.ClientLibrary doesn’t provide a sample of how the C# classes should look like for our example https://www.paste.org/102547
Is there more documentation regarding creating classes representing schemas for Squidex.ClientLibrary? The repository only contains examples with a flat schema. Any help would be deeply appreciated
Hi,
it is easy, something like this:
class PageData {
[JsonConverter(typeof(InvariantConverter))]
[JsonProperty("service-blocks")]
public ServiceBlock[] ServiceBlocks { get; set; }
}
class ServiceBlock{
public string Headline { get; set; }
}
Hi @Sebastian, thank you. Maybe I’m just tired after a long day of work, but I’m stuck again :-/
public class PageData
{
[JsonConverter(typeof(InvariantConverter))]
[JsonProperty("service-blocks")]
public ServiceBlock[] ServiceBlocks { get; set; }
}
public class ServiceBlock
{
[JsonConverter(typeof(InvariantConverter))]
public string headline { get; set; }
}
public class ServiceBlockTest : SquidexEntityBase
{
}
When we’re using
var client = clientManager.GetClient("home");
var homeTest = client.GetAsync("MY GUID").Result;
to get a reference to the content for the block, the meta data is correctly loaded but the Data property is not being deserialized and is set to null instead.
Would you be so kind and tell us where our error is?
Sorry, it is service-block
not service-blocks
.
Also you do not need the [JsonConverter(typeof(InvariantConverter))]
for your headline.
Thanks! I guess last Monday was a really long day afterall