GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
List of all members
gd::Serializer Class Reference

The class used to save/load projects and GDCore classes from/to XML or JSON. More...

#include <Serializer.h>

Static Public Member Functions

XML serialization.

Convert a gd::SerializerElement from/to XML.

static gd::String ToEscapedXMLString (const gd::String &str)
 Escape a string for inclusion in a XML tag.
 
JSON serialization.

Convert a gd::SerializerElement from/to JSON. This uses RapidJSON for fast parsing and stringification. See https://github.com/miloyip/nativejson-benchmark

static gd::String ToJSON (const SerializerElement &element)
 Serialize a gd::SerializerElement to a JSON string.
 
static SerializerElement FromJSON (const char *json)
 Construct a gd::SerializerElement from a JSON string.
 
static SerializerElement FromJSON (const gd::String &json)
 Construct a gd::SerializerElement from a JSON string.
 
Canonical serialization mode.

When enabled, ToJSON writes object keys in alphabetical order and various SerializeTo helpers write default values (false, "", []) for properties that would otherwise be omitted.

This makes git diffs minimal and shift-free when toggling boolean flags or adding/removing optional sub-structures (e.g. sub-events, local variables).

static void SetCanonicalMode (bool canonical)
 Enable/disable canonical serialization mode globally. More...
 
static bool IsCanonicalMode ()
 Returns true if canonical serialization mode is currently active.
 

Detailed Description

The class used to save/load projects and GDCore classes from/to XML or JSON.

Member Function Documentation

◆ SetCanonicalMode()

static void gd::Serializer::SetCanonicalMode ( bool  canonical)
inlinestatic

Enable/disable canonical serialization mode globally.

Affects ToJSON (alphabetical key order) and various SerializeTo helpers (always writing default values for optional properties).


The documentation for this class was generated from the following files: