-
Hello! List<MyPageType> pages = new List<MyPageType>();
foreach (Guid pageId in _db.Pages
.Where(p => p.Published <= DateTime.Now && p.PageTypeId == "MyTypePage")
.Skip(pagenumber * amount)
.Take(amount)
.Select(p => p.Id)
.ToList())
{
pages.Add(await _api.Pages.GetByIdAsync<MyTypePage>(pageId).ConfigureAwait(false));
}
return Json(pages); Everything is working fine, I'm getting all the page's infos, except the blocks list, which is coming without the contents in the JSON response, like the example below. The block contains some content if I open it on the manager. "blocks": [
{
"id": "c178679a-bc32-420c-bd85-5974d1b43b81",
"type": "Piranha.Extend.Blocks.HtmlBlock"
}
], I've tried using the IModelLoader to see if it would recover the contents, but without success (the result is the same if using the IApi to get the content). I'm using this application as an API for consuming the CMS content (without the manager). In another project, which uses the Manager, the StandardPage and the IModelLoader, the JSON response contains all blocks content. [Route("page")]
public async Task<IActionResult> Page(Guid id, bool draft = false)
{
try
{
var model = await _loader.GetPageAsync<StandardPage>(id, HttpContext.User, draft);
return Json(model);
}
catch (UnauthorizedAccessException)
{
return Unauthorized();
}
} "blocks": [
{
"$type": "Piranha.Extend.Blocks.TextBlock, Piranha",
"body": {
"value": "Hello!"
},
"id": "50e72755-b645-4f55-baf7-105a2ca9c168",
"type": "Piranha.Extend.Blocks.TextBlock"
},
] I thought it could be a question with the Microsoft's Json serializer, but it's working fine on the other project. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can’t use Microsoft’s JSON serializer with Piranha as it does not support serialization or deserialization of non finite types. Instead use Newtonsoft for serialization. |
Beta Was this translation helpful? Give feedback.
You can’t use Microsoft’s JSON serializer with Piranha as it does not support serialization or deserialization of non finite types. Instead use Newtonsoft for serialization.