DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: webb123
今日帖子: 1
在线用户: 2
导航: 论坛 -> 移动应用开发 斑竹:flyers,iamdream  
作者:
男 letianwuji (大器晚成) ▲▲▲▲▲ -
普通会员
2017/1/5 14:53:39
标题:
BackendStorage1.Storage.QueryObjects('websites/_count', [], LJSONArray); 浏览:1224
加入我的收藏
楼主: BackendStorage1.Storage.QueryObjects('websites/_count', [], LJSONArray);

Baas开发想返回总记录数,数据包发送接收从抓包工具看,执行是OK的
就是QueryObjects中LJSONArray 老是出问题....
----------------------------------------------
相信自己,若自己都不相信,那还有谁可信。
作者:
男 letianwuji (大器晚成) ▲▲▲▲▲ -
普通会员
2017/1/5 15:05:21
1楼: 提示——Invalid class typecast
----------------------------------------------
相信自己,若自己都不相信,那还有谁可信。
作者:
男 letianwuji (大器晚成) ▲▲▲▲▲ -
普通会员
2017/1/6 15:22:26
2楼: 找到原因::
procedure TKinveyApi.QueryResource(const AResource: string; const AQuery: array of string; const AJSONArray: TJSONArray;
  AReset: Boolean);
var
  LRoot: TJSONArray;
  S: String;
  I: Integer;
  LTrim: string;
  LJSONValue: TJSONValue;
  LResponse: TJSONObject;
begin
  if AReset then
  begin
    FRequest.ResetToDefaults;
    AddAuthParameter;
  end;
  FRequest.Method := TRESTRequestMethod.rmGET;
  FRequest.Resource := AResource;

  for S in AQuery do
  begin
    LTrim := Trim(S);
    if LTrim = '' then
      continue;
    I := LTrim.IndexOf('=');
    if I > 0 then
      FRequest.AddParameter(S.Substring(0, I).Trim, S.Substring(I+1).Trim);
  end;

  FRequest.Execute;
  CheckForResponseError([404]); // 404 = not found
  if AJSONArray <> nil then
    if FRequest.Response.StatusCode <> 404 then
    begin
      try
          LRoot := FRequest.Response.JSONValue as TJSONArray;
          for LJSONValue in LRoot do
          AJSONArray.AddElement(TJSONValue(LJSONValue.Clone))
      except
          LResponse := FRequest.Response.JSONValue as TJSONObject;
          if Assigned(AJSONArray) then
          AJSONArray.AddElement(LResponse.Clone as TJSONObject);
      end;
    end;
end;
----------------------------------------------
相信自己,若自己都不相信,那还有谁可信。
作者:
男 letianwuji (大器晚成) ▲▲▲▲▲ -
普通会员
2017/1/6 17:04:28
3楼: 问题的核心,是Response返回的内容:
可能是格式:[{'abc':808}]
也可能是{'abc':808}

FRequest.Response.JSONValue as TJSONArray;对有[]的完全没问题;
----------------------------------------------
相信自己,若自己都不相信,那还有谁可信。
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行69.33594毫秒 RSS