Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TJsonBindSource Component

A complete LiveBindings-enabled component for Delphi that allows you to bind JSON data to visual controls using the LiveBindings framework.

Features

  • Design-Time Schema Configuration: Configure JSON schema via context menu "Configure Schema"
  • Design-Time Data Entry: Set JSON data via context menu "Set Data"
  • Runtime Data Binding: Use SetData() method to bind data at runtime
  • LiveBindings Integration: Works seamlessly with Delphi's LiveBindings designer
  • Type Support: Supports string, integer, float, and boolean types
  • FMX Compatible: Works with FireMonkey applications

Installation

1. Compile and Install Runtime Package

  1. Open Packages\JsonBindSourceRT.dpk in Delphi
  2. Right-click on the project and select "Build"
  3. The package will be compiled but not installed (runtime-only)

2. Compile and Install Design-Time Package

  1. Open Packages\JsonBindSourceDT.dpk in Delphi
  2. Right-click on the project and select "Build"
  3. Right-click on the project and select "Install"
  4. The component will appear in the "LiveBindings" palette

Usage

Design-Time Usage

  1. Drop a TJsonBindSource component on your form
  2. Right-click the component and select "Configure Schema..."
  3. Enter your JSON schema (or click "Load Sample")
  4. Right-click the component and select "Set Data..."
  5. Enter your JSON data (or click "Load Sample")
  6. Open the LiveBindings designer
  7. Create bindings from the JSON fields to your visual controls

JSON Schema Format

The component supports two schema formats:

Full Format (Standard)

{
  "fields": [
    {"name": "id", "type": "integer"},
    {"name": "name", "type": "string"},
    {"name": "email", "type": "string"},
    {"name": "age", "type": "integer"},
    {"name": "salary", "type": "float"},
    {"name": "active", "type": "boolean"}
  ]
}

Short Format (Compact)

{
  "id": "integer",
  "name": "string",
  "email": "string",
  "age": "integer",
  "salary": "float",
  "active": "boolean"
}

Both formats are automatically recognized and converted internally. The short format is more concise and convenient for simple schemas.

Runtime Usage

// Configure schema at runtime
JsonBindSource1.JsonSchema.Text := '{"fields": [...]}';

// Set data using the SetData method
var
  JsonData: string;
begin
  JsonData := '{"id": 1, "name": "John Doe", "email": "john@example.com"}';
  JsonBindSource1.SetData(JsonData);
  JsonBindSource1.Active := True;
end;

// Clear data
JsonBindSource1.ClearData;

Demo Application

The Demo folder contains a complete FMX application demonstrating the component usage:

  1. Open Demo\JsonBindSourceDemo.dproj in Delphi
  2. Run the application
  3. Click "Load Data" buttons to see LiveBindings in action

Project Structure

TJsonBindSource/
├── Source/
│   ├── JsonBindSource.pas          # Main component (runtime)
│   ├── JsonSchemaEditor.pas        # Schema configuration dialog
│   ├── JsonSchemaEditor.fmx        # Schema editor form
│   ├── JsonDataEditor.pas          # Data entry dialog
│   ├── JsonDataEditor.fmx          # Data editor form
│   └── JsonBindSourceReg.pas       # Design-time registration
├── Packages/
│   ├── JsonBindSourceRT.dpk        # Runtime package
│   └── JsonBindSourceDT.dpk        # Design-time package
└── Demo/
    ├── JsonBindSourceDemo.dpr      # Demo application
    ├── MainForm.pas                # Main form
    └── MainForm.fmx                # Main form layout

Requirements

  • Delphi 10 Seattle or later (RAD Studio 19.0+)
  • FireMonkey (FMX) framework
  • LiveBindings components

Technical Details

The component is based on TBaseObjectBindSource and implements a custom adapter (TJsonBindSourceAdapter) that:

  • Parses JSON schema to define fields
  • Parses JSON data and exposes values through LiveBindings
  • Supports the standard LiveBindings member getter interface
  • Integrates with the LiveBindings designer

License

Boost Software License - Version 1.0

About

A complete LiveBindings-enabled component for Delphi that allows you to bind JSON data to visual controls using the LiveBindings framework.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages