自定義JSON名

redhat588發表於2024-08-15
 lSer := TMVCJsonDataObjectsSerializer.Create;
            try
              lSer.DataSetToJsonArray(MasterDBHelper.Query, lJObj.a['m'], TMVCNameCase.ncLowerCase, [],
                procedure(const aField: TField; const aJsonObject: TJSONObject; var Handled: Boolean)
                begin
                  if SameText(aField.FieldName, 'ma001') then
                  begin
                    aJsonObject.S['id'] := aField.Value;

                    Handled := True;    //原ma001值不顯示
                  end;
                  if SameText(aField.FieldName, 'ma003') then
                  begin
                    aJsonObject.S['idname'] := aField.Value;

                    Handled := True;    //原ma003值不顯示
                  end;

                end);

            finally
              lSer.Free;
            end;
{            
    "id": "101",
     ma002": "辛潮家居",
    "idname": "上海辛潮家居有限公司"
}

相關文章