[TechSpeak] Sitecore 9.2 Version: A New Format for Serialization

Updated Apr 8, 2024

In April 2019, I wrote the article announcing the forthcoming Sitecore upgrade. And here it is —  the version 9.2 of Sitecore Experience Platform has been officially released on July 22, 2019.

Today, I will not tell you about all the new features in Sitecore 9.2 but would like to draw your attention to the serialization mechanism.

The process of serialization helps transform data items to text files or memory buffers for their further storage, transfer and reconstruction. It is especially useful for a team of developers who work together on the same project and need to seamlessly synchronize changes between their individual development environments.

In Sitecore 9.2, a new serialization config file appeared in the CMS.Core folder: App_Config\Sitecore\CMS.Core\Sitecore.Serialization.config file.

Sitecore-9.2-serialization-photo

This file contains different parameters. The most interesting of them are:

  • Serialization type (currently, there are two possible variants — default and YAML; keep in mind that by default it is not YAML)

<setting name=”Serialization.SerializationType” value=”default” />

Sitecore-Serialization-YAML-photo
  • Serialization folder (the root of the serialized items)

<setting name=”SerializationFolder” value=”$(dataFolder)/serialization” />

Config Data Folder
  • Field formatters (only works with YAML and defines serialization rules for specific item field types; if you have your custom field type, you will need to develop your own formatter and put it into this section)
    Sitecore-serialization-field-formatters-photo
  • Predicate (only works with YAML; defines which roots should be serialized; by default, two values are used – master and core, that means that the serialization process will serialize all items defined under /Sitecore content path for both core and master database)
  • userPredicate (initially, it’s an empty section; only works with YAML)
    <userPredicate></userPredicate>
    Sitecore-serialization-User-Predicate-photo
  • rolePredicate (initially, it’s an empty section; only works with YAML)
    <rolePredicate></rolePredicate>
    Sitecore-serialization-Role-Predicate-photo

How Can You Execute Serialization Functions in Sitecore?

There are three options:

Sitecore-9.2-Manual-Serialization-photo

1. Do it manually in the Content Editor

2. Do it automatically by using Sitecore event handlers. For instance:

Serialization-functions-photo

3. Use the Sitecore service page

[your Sitecore cm instance host name]/sitecore/admin/serialization.aspx

Way3_Serialization

I’d like to perform both default and YAML serialization manually. Well, I have Sitecore 9.2 installed. Let’s serialize one item using Sample Rendering item (it goes out of the box):

Sample Render

To serialize this item manually, I have to engage the Developer tab in the Content Editor (right click on any place at the top Content Editor Sitecore ribbon and select Developer).

Developer_Panel

Then, select Sample Rendering item, and in the appeared panel click Serialize item.

Serialization-in-Sitecore-photo

As I’ve mentioned before, we have a default serialization (by default). The serialized result is located in the data folder that was specified in the config file (by default App_Data/serialization).

CE SerializeItem

Let’s open this file. It looks like this:

Default-Serialization-Sitecore-image

Now, let’s change the default serialization to YAML.

Yaml-serialization-photo

In the config file, change the parameter Serialization type to YAML. But be careful, for the YAML serialization we have a Predicate parameter which serializes all items. In our case, we want to serialize only one item that’s why we change the predicate as follows:

Yaml2

Don’t forget to save changes and go back to the Content Editor. Repeat the serialization process once again. In the folder, the serialized item in the YAML format appears. Take a look at the result:

Yaml-result

Below you can see the comparison of the default and YAML files:

Serialization-in-Sitecore-9.2-photo

To Sum Up

It’s great news that Sitecore has implemented YAML for serialization as this format is very convenient and widely used by developers.

Some benefits of YAML:

  1. YAML is a human-friendly format
  2. It is not comma separated
  3. It Supports different datatypes
  4. It is used by many technologies and is gaining popularity

Read more about Sitecore Serialization here.

Happy serialization, Sitecorian friends  🙂

One Comment
Leave a comment
  • I blog frequently and I really thank you for your information. The article has truly peaked my interest.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>