diff --git a/samples/delphi/configuration/src/DataSet.Serialize.Samples.Configuration.pas b/samples/delphi/configuration/src/DataSet.Serialize.Samples.Configuration.pas
index 5f5ff92..4c182e5 100644
--- a/samples/delphi/configuration/src/DataSet.Serialize.Samples.Configuration.pas
+++ b/samples/delphi/configuration/src/DataSet.Serialize.Samples.Configuration.pas
@@ -113,7 +113,7 @@ procedure TFrmSamples.Button1Click(Sender: TObject);
begin
LJSONArray := mtUsers.ToJSONArray;
try
- memoJSON.Lines.Text := {$IFDEF CompilerVersion > 32}LJSONArray.Format{$ELSE}LJSONArray.ToJSON{$ENDIF};
+ memoJSON.Lines.Text := {$IFDEF CompilerVersion < 33}LJSONArray.ToJSON{$ELSE}LJSONArray.Format{$ENDIF};
finally
LJSONArray.Free;
end;
diff --git a/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.dfm b/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.dfm
index 8cee675..dc36300 100644
--- a/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.dfm
+++ b/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.dfm
@@ -181,8 +181,6 @@ object FrmSamples: TFrmSamples
ReadOnly = True
ScrollBars = ssVertical
TabOrder = 1
- ExplicitLeft = 3
- ExplicitTop = -6
end
end
object Panel5: TPanel
@@ -464,7 +462,6 @@ object FrmSamples: TFrmSamples
Align = alClient
BevelOuter = bvNone
TabOrder = 1
- ExplicitWidth = 722
object Panel16: TPanel
Left = 0
Top = 150
@@ -473,7 +470,6 @@ object FrmSamples: TFrmSamples
Align = alClient
BevelOuter = bvNone
TabOrder = 0
- ExplicitWidth = 722
object Panel17: TPanel
Left = 0
Top = 0
@@ -492,7 +488,6 @@ object FrmSamples: TFrmSamples
ParentBackground = False
ParentFont = False
TabOrder = 0
- ExplicitWidth = 722
end
object DBGrid5: TDBGrid
Left = 0
@@ -525,7 +520,6 @@ object FrmSamples: TFrmSamples
Align = alTop
BevelOuter = bvNone
TabOrder = 1
- ExplicitWidth = 722
object Panel19: TPanel
Left = 0
Top = 0
@@ -544,7 +538,6 @@ object FrmSamples: TFrmSamples
ParentBackground = False
ParentFont = False
TabOrder = 0
- ExplicitWidth = 722
end
object DBGrid6: TDBGrid
Left = 0
diff --git a/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.pas b/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.pas
index 3848bca..8293758 100644
--- a/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.pas
+++ b/samples/delphi/master-detail/src/DataSet.Serialize.Samples.Master.Detail.pas
@@ -94,7 +94,7 @@ procedure TFrmSamples.btnExportArrayValueClick(Sender: TObject);
begin
LJSONArray := mtUsers.ToJSONArray;
try
- memoExportArrayValue.Lines.Text := LJSONArray.Format(2);
+ memoExportArrayValue.Lines.Text := {$IFDEF CompilerVersion < 33}LJSONArray.ToJSON{$ELSE}LJSONArray.Format{$ENDIF};
finally
LJSONArray.Free;
end;
@@ -109,7 +109,7 @@ procedure TFrmSamples.btnExportJSONArrayClick(Sender: TObject);
begin
LJSONArray := mtCountries.ToJSONArray;
try
- memoExportedDataSetNested.Lines.Text := LJSONArray.Format(2);
+ memoExportedDataSetNested.Lines.Text := {$IFDEF CompilerVersion < 33}LJSONArray.ToJSON{$ELSE}LJSONArray.Format{$ENDIF};
finally
LJSONArray.Free;
end;
diff --git a/src/DataSet.Serialize.Export.pas b/src/DataSet.Serialize.Export.pas
index 5d2c0d5..5029425 100644
--- a/src/DataSet.Serialize.Export.pas
+++ b/src/DataSet.Serialize.Export.pas
@@ -26,26 +26,35 @@ TDataSetSerialize = class
///
/// Refers to the DataSet that you want to export the record.
///
+ ///
+ /// Only export the value when there is only 1 field in the DataSet.
+ ///
///
/// Returns a JSON object containing the record data.
///
///
/// Invisible or null fields will not be exported.
///
- function DataSetToJSONObject(const ADataSet: TDataSet; const AValue: Boolean = true): TJSONObject;
+ function DataSetToJSONObject(const ADataSet: TDataSet; const AValue: Boolean = True): TJSONObject;
///
/// Creates an array of JSON objects with all DataSet records.
///
///
/// Refers to the DataSet that you want to export the records.
///
+ ///
+ /// Inform if it's child records.
+ ///
+ ///
+ /// Inform if it's to export only field values (when there is only 1 field in the DataSet).
+ ///
///
/// Returns a JSONArray with all records from the DataSet.
///
///
/// Invisible or null fields will not be exported.
///
- function DataSetToJSONArray(const ADataSet: TDataSet; const IsChild: Boolean; const isValue: Boolean = true ): TJSONArray;
+ function DataSetToJSONArray(const ADataSet: TDataSet; const IsChild: Boolean; const IsValue: Boolean = True): TJSONArray;
///
/// Encrypts a blob field in Base64.
///
@@ -66,7 +75,7 @@ TDataSetSerialize = class
///
/// Responsible for creating a new instance of TDataSetSerialize class.
///
- constructor Create(const ADataSet: TDataSet; const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; const AValueRecords: Boolean = true);
+ constructor Create(const ADataSet: TDataSet; const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; const AValueRecords: Boolean = True);
///
/// Creates an array of JSON objects with all DataSet records.
///
@@ -117,7 +126,7 @@ function TDataSetSerialize.ToJSONObject: TJSONObject;
Result := DataSetToJSONObject(FDataSet);
end;
-function TDataSetSerialize.DataSetToJSONArray(const ADataSet: TDataSet; const IsChild: Boolean; const isValue: Boolean = true): TJSONArray;
+function TDataSetSerialize.DataSetToJSONArray(const ADataSet: TDataSet; const IsChild: Boolean; const IsValue: Boolean = True): TJSONArray;
var
LBookMark: TBookmark;
begin
@@ -138,7 +147,7 @@ function TDataSetSerialize.DataSetToJSONArray(const ADataSet: TDataSet; const Is
ADataSet.Next;
Continue;
end;
- if (ADataSet.FieldCount = 1) and (isValue) then
+ if (ADataSet.FieldCount = 1) and (IsValue) then
begin
case ADataSet.Fields[0].DataType of
TFieldType.ftBoolean:
@@ -175,7 +184,7 @@ function TDataSetSerialize.DataSetToJSONArray(const ADataSet: TDataSet; const Is
end;
end
else
- Result.AddElement(DataSetToJSONObject(ADataSet));
+ Result.AddElement(DataSetToJSONObject(ADataSet, IsValue));
{$ENDIF}
ADataSet.Next;
end;
@@ -186,7 +195,7 @@ function TDataSetSerialize.DataSetToJSONArray(const ADataSet: TDataSet; const Is
end;
end;
-function TDataSetSerialize.DataSetToJSONObject(const ADataSet: TDataSet; const AValue: Boolean = true): TJSONObject;
+function TDataSetSerialize.DataSetToJSONObject(const ADataSet: TDataSet; const AValue: Boolean = True): TJSONObject;
var
LKey: string;
{$IF NOT DEFINED(FPC)}
@@ -247,7 +256,7 @@ function TDataSetSerialize.DataSetToJSONObject(const ADataSet: TDataSet; const A
TFieldType.ftDataSet:
begin
LNestedDataSet := TDataSetField(LField).NestedDataSet;
- Result.AddPair(LKey, DataSetToJSONArray(LNestedDataSet, AValue));
+ Result.AddPair(LKey, DataSetToJSONArray(LNestedDataSet, False, AValue));
end;
{$ENDIF}
TFieldType.ftGraphic, TFieldType.ftBlob, TFieldType.ftOraBlob{$IF NOT DEFINED(FPC)}, TFieldType.ftStream{$ENDIF}:
@@ -397,7 +406,7 @@ function TDataSetSerialize.SaveStructure: TJSONArray;
end;
end;
-constructor TDataSetSerialize.Create(const ADataSet: TDataSet; const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; const AValueRecords: Boolean = true);
+constructor TDataSetSerialize.Create(const ADataSet: TDataSet; const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; const AValueRecords: Boolean = True);
begin
FDataSet := ADataSet;
FOnlyUpdatedRecords := AOnlyUpdatedRecords;
diff --git a/src/DataSet.Serialize.pas b/src/DataSet.Serialize.pas
index 7ce2e58..8bbb29c 100644
--- a/src/DataSet.Serialize.pas
+++ b/src/DataSet.Serialize.pas
@@ -78,13 +78,16 @@ TDataSetSerializeHelper = class Helper for TDataSet
///
/// Exports only childs records from child datasets.
///
+ ///
+ /// Inform if it's to export only field values (when there is only 1 field in the DataSet)
+ ///
///
/// Returns a JSONArray with all records from the DataSet.
///
///
/// Invisible fields will not be generated.
///
- function ToJSONArray(const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; AValueRecords: Boolean = true): TJSONArray;
+ function ToJSONArray(const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; AValueRecords: Boolean = True): TJSONArray;
///
/// Responsible for exporting the structure of a DataSet in JSON Array format.
///
@@ -217,7 +220,7 @@ implementation
{$ENDIF}
DataSet.Serialize.Export, DataSet.Serialize.Import;
-function TDataSetSerializeHelper.ToJSONArray(const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; AValueRecords: Boolean = true): TJSONArray;
+function TDataSetSerializeHelper.ToJSONArray(const AOnlyUpdatedRecords: Boolean = False; const AChildRecords: Boolean = True; AValueRecords: Boolean = True): TJSONArray;
var
LDataSetSerialize: TDataSetSerialize;
begin