danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AV when json string is invalid

HeZiHang opened this issue · comments

ObjectsMapper.pas

class procedure Mapper.LoadJSONObjectFieldsStringToObject(AJSONObjectString: string;
AObject: TObject);
var
lJSON: TJSONObject;
begin
lJSON := TJSONObject.ParseJSONValue(AJSONObjectString) as TJSONObject;
try
InternalJSONObjectFieldsToObject(ctx, lJSON, AObject);
finally
lJSON.Free;
end;
end;

change to:
class procedure Mapper.LoadJSONObjectFieldsStringToObject(AJSONObjectString: string;
AObject: TObject);
var
lJSON: TJSONObject;
begin
lJSON := TJSONObject.ParseJSONValue(AJSONObjectString) as TJSONObject;
if Assigned(IJSON) then
try
InternalJSONObjectFieldsToObject(ctx, lJSON, AObject);
finally
lJSON.Free;
end;
end;