-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Milestone
Description
TJsonField = record
fHasField: boolean;
fPair: TJSONPair;
constructor Create(const aField: string; const aValue: Variant);
function HasDate: boolean;
function AsString: strong;
function AsDate: TDateTime;
function AsInteger: integer;
function AsBoolean: boolean;
procedure SetValue(const aText: string); overloaded;
procedure SetValue(const aDate: TDateTime);
procedure SetValue(const aValue: integer);
procedure SetValue(const aValue: boolean);
end;
function CreateJsonObject(aObjectData: TArray<TJsonField>): TJSONObject;
// function TDataSetHelper.AsJson: TJSONArray;
TJsonValueHelper = class helper for TJSONValue
function IsJsonArray: boolean;
function IsJsonObject: boolean;
function HasField(const aKey: string): boolean; // expects JSONArray
function GetField(const aKey: string): TJsonField; // expects JSONArray
function TryGetField(const aKey: string; out aJsonField: TJsonField): boolean;
// --
procedure AddField(const aKey: string; const aValue: Variant);
procedure AddObject(aObjectData: TArray<TJsonField>); // expects JSONArray
// --
// LoadFromFile, LoadFromStream, SaveToFile, SaveToStream
// FromDBField, WriteToDBField - expects not TJSONObject and not TJSONArray
// FromDataRow, WriteToDataRow - expects TJSONObject
// CreateClientDataSet - expects TJSONArray
end;
Sample JSONs (review):