Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AFieldNamePolicy: TFieldNamePolicy to TDataSetHelper.AsJSONObjectString #78

Open
Ravaut123 opened this issue Mar 23, 2017 · 0 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone task

Comments

@Ravaut123
Copy link

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;
@danieleteti danieleteti self-assigned this May 7, 2017
@danieleteti danieleteti added this to the 3.1 (helium) milestone Jul 2, 2018
@danieleteti danieleteti added the accepted Issue has been accepted and inserted in a future milestone label Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone task
Projects
None yet
Development

No branches or pull requests

2 participants