Skip to content

Commit

Permalink
Bug fix lazarus
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Dec 14, 2023
1 parent 54aeba4 commit 7a036ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/DataSet.Serialize.pas
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,19 @@ procedure TDataSetSerializeHelper.LoadFromJSON(const AJSONObject: TJSONObject; c

procedure TDataSetSerializeHelper.LoadFromJSON(const AJSONObject: TJSONObject; const ARootElement: string = ''; const AOwns: Boolean = True);
var
LJSON: TJSONValue;
LJSON: {$IF DEFINED(FPC)}TJSONData{$ELSE}TJSONValue{$ENDIF};
LJSONSerialize: TJSONSerialize;
begin
if ARootElement.Trim.IsEmpty then
LJSONSerialize := TJSONSerialize.Create(AJSONObject, AOwns)
else
begin
try
{$IF DEFINED(FPC)}
LJSON := AJSONObject.Find(ARootElement);
{$ELSE}
LJSON := AJSONObject.FindValue(ARootElement);
{$ENDIF}
if not Assigned(LJSON) then
raise Exception.Create('Root element not found!');
if LJSON.InheritsFrom(TJSONArray) then
Expand Down Expand Up @@ -431,4 +435,4 @@ procedure TDataSetSerializeHelper.MergeFromJSONObject(const AJSONString: string)
MergeFromJSONObject({$IF DEFINED(FPC)}GetJSON(AJSONString){$ELSE}TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(AJSONString), 0){$ENDIF} as TJSONObject)
end;

end.
end.

0 comments on commit 7a036ca

Please sign in to comment.