Skip to content

TJSONToPascal

Main class for generating Pascal code from JSON data

Declaration

Source position: fpjsontopas.pp line 75

type

  TJSONToPascal = class(TComponent)
  public
    constructor Create;
    destructor Destroy;
    procedure Execute;
    property JSONData: TJSONData; {rw}
    property JSONStream: TStream; {rw}
  published
    property Active: Boolean; {rw}
    property Options: TJSONToPascalOptions; {rw}
    property JSON: TJSONStringType; {rw}
    property Code: TStrings; {rw}
    property PropertyMap: TPropertyMap; {rw}
    property DestUnitName: string; {rw}
    property DefaultParentName: string; {rw}
    property IndentSize: Integer; {rwd}
    property ExtraUnitNames: string; {rw}
    property PropertyTypeSuffix: string; {rw}
    property FieldPrefix: string; {rw}
    property ObjectConstructorArguments: string; {rw}
    property ToplevelObjectClassName: string; {rw}
  end;

Description

TJSONToPascal is the core component that generates Object Pascal class definitions from JSON data structures. It analyzes the JSON input and creates complete Pascal unit code with classes that can serialize to and from JSON format.

The class provides comprehensive control over the code generation process through various properties and options. Generated classes include appropriate property declarations, constructor/destructor methods, and optional JSON serialization methods.

Properties

Member Visibility Description
Active published Automatically execute code generation when set to True
Code published Generated Pascal unit code
DefaultParentName published Default base class for generated objects
DestUnitName published Name of the generated Pascal unit
ExtraUnitNames published Additional units for the uses clause
FieldPrefix published Prefix for private field names
IndentSize published Number of spaces for code indentation
JSON published JSON string to generate code from
JSONData public JSON data object to generate code from
JSONStream public Stream containing JSON data to generate code from
ObjectConstructorArguments published Arguments for object constructors
Options published Code generation options
PropertyMap published Manual type mappings for JSON properties
PropertyTypeSuffix published Suffix for generated object and array type names
ToplevelObjectClassName published Name of the main generated class
See all Properties

Methods

Member Visibility Description
Create public Creates a new TJSONToPascal instance
Destroy public Destroys the TJSONToPascal instance
Execute public Generates Pascal code from JSON data
See all Methods