Object serialization to JSON format

Objects can be serialized out to the JSON format . JSON is a machine-readable format that’s also designed to be easy for humans to read and edit, so that contributors can make small changes to data without requiring specialized tools or a detailed XML schema. Many programming languages also offer robust and easy to use support for JSON data, making the development of build and design tools for supporting your project outside of the O3DE editor easy.

In O3DE, using the JSON serialization format also offers the following benefits:

  • Minimal serialization - Only data relevant to the object is serialized. Default values and information that can be retrieved at runtime aren’t stored. This reduces object size and makes manual editing easier.
  • Best-effort deserialization - To complement the minimal serialization, the engine applies as much data as possible when deserializing. If a field is missing from the JSON input, default values are used. Fields in the JSON which aren’t supported by the object are ignored. This makes working with JSON less error-prone than XML, which requires a rigid structure.
  • Forgiving - Because of the forgiving nature of JSON, serialization and deserialization can proceed even if it finds missing data while emitting a warning (and optionally reporting an error.) This extends to specialized data types used by O3DE such as vectors: If a 3D vector contains a 4th coordinate, it’s simply ignored and a warning is reported. This makes manual editing and custom tooling much safer.
  • Easier to use with source control - Source control systems can have difficulty with merging or generating useful diffs with XML files. Because of JSON’s flexibility and limited format, it’s easier to work with JSON files in your source control system as text files.

This section of the documentation covers serialization and deserialization of data in the JSON format, and how O3DE data types are mapped to JSON data types.


Copyright © 2022 Open 3D Engine Contributors

Documentation Distributed under CC BY 4.0.
For our trademark, privacy and antitrust policies, code of conduct, and terms of use, please click the applicable link below or see https://www.lfprojects.org.

The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Policy page.