Try our conversational search powered by Generative AI!

Converting PageData to Json



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.



Dec 18, 2019 13:27
Vincent - Jan 17, 2020 13:32
Have you tried the following package?

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

Edited, Dec 18, 2019 13:31

What does ToRawPage do?

Dec 18, 2019 14:43

ToRawPage is obsolete, but it creates RawContentInfo.

Consider EPiServer.Core.Transfer.Internal.IRawContentRetriever instead.

Dec 18, 2019 15:04

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. 

Dec 18, 2019 15:38

I wonder if it is possible to get the json from FIND

Dec 18, 2019 15:44

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.

Dec 18, 2019 18:03

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);
Jan 15, 2020 13:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.