Skip to content

TJSONApplier

Component class for applying (merging) JSON objects

Declaration

Source position: fpjsonapply.pp line 37

type

  TJSONApplier = class(TComponent)
  public
    destructor destroy;
    procedure Execute;
    property SourceJSON: TJSONObject; {rw}
    property ApplyJSON: TJSONObject; {rw}
    property DestJSON: TJSONObject; {r}
    property OwnsJSON: TOwnsJSONs; {rw}
  published
    property SourceFileName: string; {rw}
    property SourcePath: string; {rw}
    property ApplyFileName: string; {rw}
    property ApplyPath: string; {rw}
    property DestFileName: string; {rw}
    property CloneSource: Boolean; {rw}
    property CaseInsensitive: Boolean; {rw}
    property ForceCorrectType: Boolean; {rw}
    property RemoveNonExisting: Boolean; {rw}
    property Formatted: Boolean; {rw}
  end;

Description

The TJSONApplier class is a component that provides functionality to apply (merge) elements from one JSON object to another. It supports loading JSON objects from files or working with existing objects in memory, with various configuration options for controlling the merge behavior. The component can merge at specific paths within JSON structures, handle type conflicts, control case sensitivity, and manage object ownership.

Properties

Member Visibility Description
ApplyFileName published Filename to load apply JSON from if ApplyJSON is not set
ApplyJSON public JSON object containing elements to apply to the source
ApplyPath published JSON path in apply object where merging data should be taken from
CaseInsensitive published Controls whether property name matching is case sensitive
CloneSource published Controls whether to make a clone copy of source JSON before applying changes
DestFileName published Filename to write the destination JSON to after merging
DestJSON read only public Destination JSON object containing the merge result
ForceCorrectType published Controls whether to overwrite properties when types differ between source and apply JSON
Formatted published Controls whether output JSON is formatted with indentation and line breaks
OwnsJSON public Set specifying which JSON objects are owned by the component
RemoveNonExisting published Controls whether to remove properties from source that do not exist in apply JSON
SourceFileName published Filename to load source JSON from if SourceJSON is not set
SourceJSON public Source JSON object to merge into
SourcePath published JSON path in source object where merging should start
See all Properties

Methods

Member Visibility Description
destroy public Destructor that frees owned JSON objects and cleans up resources
Execute public Executes the JSON merge operation from apply JSON to source JSON
See all Methods

Errors

Raises EJSON exceptions when:

  • Source or apply JSON objects are empty
  • JSON files do not contain valid JSON objects
  • Specified paths are not found in the JSON structures

See also

Name Description
TOwnsJSON Enumeration values for JSON object ownership control
TOwnsJSONs Set of JSON object ownership flags