There is built in export functionality but it doesn't export in json though.
You can rename export file to .zip and unpack it and you will get an xml file with properties etc
ToRawPage is obsolete, but it creates RawContentInfo.
Consider EPiServer.Core.Transfer.Internal.IRawContentRetriever instead.
You can always serialize it yourself using Newtonsoft json serializer. I think you will need to configure the serialization a bit though since PageData is quite a deep structure.
I've done that a couple of times to log pages.
Find is json already and if you "hijack" the response coming back (that is an ordinary elastic response so you could do it with for example NEST) you will get it in Find-Json.
I've seen a few times that json serializing the ContentData throws exception due to circular references and/or complex objects.
I would suggest that you create your own json serialization, or use the serialization from Content Delivery API in your custom API Controller that lists ALL your Content, or something that saves the json into a file.
Quick example:
public IHttpActionResult Get()
{
IEnumerable<IContent> contentToExport = GetContentToExport();
var contentModelMapperFactory = ServiceLocator.Current.GetInstance<IContentModelMapperFactory>();
List<ContentApiModel> contentApiModelList = new List<ContentApiModel>();
foreach (IContent content in contentToExport)
{
IContentModelMapper mapper = contentModelMapperFactory.GetMapper<IContent>(content);
contentApiModelList.Add(mapper.TransformContent(content, false, "*"));
}
return new ContentApiResult<IEnumerable<ContentApiModel>>(contentApiModelList, HttpStatusCode.OK);
}
Hi,
I would like to export all pages or a specific pagetype into JSon so we can export the data into another CMS.
Is this possible?
We are currenlty using Episerver 7.10.
Thanks
Jon
https://github.com/joseftw/JOS.ContentSerializer