[Feature] Support for Delphi-Style Modern JSON Serialization

Summary

Add support in FPC for the modern Delphi JSON serialization framework introduced in Delphi 10.3 Rio (System.JSON.Serializers), including full support for generic serialization/deserialization of objects, collections, and complex types.

Delphi’s modern JSON serializer provides attribute-based configuration, automatic handling of generics, converters, contract resolution, and a high-level API via TJsonSerializer. This greatly simplifies JSON ↔️ object mapping compared to manually constructing JSON using fcl-json.

Free Pascal already provides System.JSON, but it lacks:

  • System.JSON.Serializers
  • System.JSON.Types
  • System.JSON.Readers
  • System.JSON.Writers
  • System.JSON.Converters
  • Attribute-based serialization ecosystem
  • Generic-aware serialization/deserialization

System Information

Not platform-specific. Applies to all FPC-supported platforms.

Relevant 3rd-party Information

Delphi Documentation

Modern JSON serialization in Delphi:

https://docwiki.embarcadero.com/Libraries/Florence/en/System.JSON
https://docwiki.embarcadero.com/Libraries/Florence/en/System.JSON.Serializers

Delphi Version Compatibility

Modern serializer first appeared in:

  • Delphi 10.3 Rio

Includes:

  • System.JSON.Serializers
  • TJsonSerializer
  • TJsonTypeInfo, TJsonConverter, TJsonReader, TJsonWriter, etc.
  • Full generic support for JSON serialization/deserialization
  • Attribute-based serialization (JsonName, JsonNumberHandling, converters, etc.)

Example Project

type
  TPerson = class
  public
    Name: string;
    Age: Integer;
  end;

var
  P: TPerson;
  Json: string;
begin
  P := TPerson.Create;
  P.Name := 'Alice';
  P.Age := 30;

  Json := TJsonSerializer.Serialize<TPerson>(P);
  // {"Name":"Alice","Age":30}

  P := TJsonSerializer.Deserialize<TPerson>(Json);
end;

Motivation

  • Improves modern Delphi compatibility
  • Enables cross-compilation of Delphi codebases
  • Provides robust attribute-based JSON serialization for FPC
Assignee Loading
Time tracking Loading