danieleteti/delphimvcframework

AV when json string is invalid

HeZiHang opened this issue · 0 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;