delphimvcframework icon indicating copy to clipboard operation
delphimvcframework copied to clipboard

add AFieldNamePolicy: TFieldNamePolicy to TDataSetHelper.AsJSONObjectString

Open Ravaut123 opened this issue 7 years ago • 0 comments

Error in unitest:

function TRESTClient.DataSetInsert(const AResource: string; ADataSet: TDataSet; AFieldNamePolicy: TFieldNamePolicy) : IRESTResponse; begin Result := doPOST(AResource, [], ADataSet.AsJSONObjectString(False, AFieldNamePolicy)); end;

Add TFieldNamePolicy

function TDataSetHelper.AsJSONObjectString(AReturnEmptyStringIfEOF: boolean;  AFieldNamePolicy: TFieldNamePolicy): string;
var
  JObj: TJSONObject;
begin
  JObj := AsJSONObject(True, AFieldNamePolicy);
  if not Assigned(JObj) then
  begin
    if AReturnEmptyStringIfEOF then
      Result := ''
    else
      Result := '{}';
  end
  else
    try
      { .$IFDEF TOJSON }
      Result := JObj.ToJSON;
      { .$ELSE }
      // Result := JObj.ToString
      { .$IFEND }
    finally
      JObj.Free;
    end;
end;

Ravaut123 avatar Mar 23 '17 15:03 Ravaut123