marlonnardi / JsonToDelphi

generate delphi classes from json (Json To Delphi Class Generator / JSON Data Binding Tool FMX, VCL and uniGUI)
https://jsontodelphi.com
64 stars 25 forks source link

Delphi-JsonToDelphiClass

This is a fork of Petar Georgiev with improvements of Jens Borrisholt

JsonToDelphi Online

https://jsontodelphi.com

Origin [Jens Borrisholt] (https://github.com/JensBorrisholt/Delphi-JsonToDelphiClass)

Fixes & Features: 16th June 2024

Features

Eg this JSON

[
    {
        "createdAt": null,
        "updatedAt": "2013-05-28T15:47:57.962Z",
        "username": "jacquelyn88"
    }
]

Generates the following DTO:

  TItems = class
  private
    FCreatedAt: string;
    [SuppressZero]
    FUpdatedAt: TDateTime;
    FUsername: string;
  published
    property CreatedAt: string read FCreatedAt write FCreatedAt;
    property UpdatedAt: TDateTime read FUpdatedAt write FUpdatedAt;
    property Username: string read FUsername write FUsername;
  end;

Fixes & Features: 19th January 2024

Features

Bugs:

Fixes & Features: 06th February 2022

Features

Fixes & Features: 26h December 2021

Features

Bugs:

Fixes & Features: 03h October 2021

Bugs:

Features

A Small example:

type
  TDateTimeDTO = class(TJsonDTO)
  private
    [SuppressZero]
    FSuppressDate: TDateTime;
    FNoSuppressDate: TDateTime;
  public
    property DateSuppress: TDateTime read FSuppressDate write FSuppressDate;
    property NoDateSuppress: TDateTime read FNoSuppressDate write FNoSuppressDate;
  end;

The above class will generate the following JSON, if both properties is 0

{
  "suppressDate": "",
  "noSuppressDate": "1899-12-30T00:00:00.000Z"
}

NOTE: You can turn off this feature in the settings form

Fixes & Features: 04th June 2021

Bugs:

Features

Fixes & Features: 26th Marts 2021

Bugs:

E.g this JSON generated faulty code:

{
  "/": {
    "readonly": true
  },
  "\\": {
    "readonly": true
  }
}

Fixes & Features: 22th December 2020

Bugs:

Features

Fixes & Features: 11th December 2020

Bugs:

Features

Fixes & Features: 24th November 2020

Bugs:

Features

Fixes & Features: 22th November 2020

Bugs:

Features

Eg this JSON

{
  "ArrayTest": [
    {
      "S1": "5102"
    },
    {
      "S2": "True"
    }
  ]
}

Generates the following DTO:

  TArrayTestDTO = class
  private
    FS1: string;
    FS2: string;
  published
    property S1: string read FS1 write FS1;
    property S2: string read FS2 write FS2;
  end;

Previous changes

Generates Delphi Classes based on JSON string. Just like XML Data Binding, but for JSON.

Main features

*** The releases of JsonToDelphiClass (source and binaries) are public and reside on GitHub. The update unit uses GitHub's REST API to enumerate tags/releases.

Report any problems/suggestions using GitHub's facilities.