Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
超对象JSON错误_Json_Delphi - Fatal编程技术网

超对象JSON错误

超对象JSON错误,json,delphi,Json,Delphi,这里是ShowMessagejson.AsJSONtrue;输出: Node.js服务器错误: Node.js代码: procedure TForm1.kClick(Sender: TObject); var selected: String; json: ISuperObject; begin j:=0; json := TSuperObject.Create('{}'); json.S['slide']:= '1'; for i:= 0 to Dest.Count

这里是ShowMessagejson.AsJSONtrue;输出:

Node.js服务器错误:

Node.js代码:

procedure TForm1.kClick(Sender: TObject);
var
  selected: String;
  json: ISuperObject;
begin
  j:=0;
  json := TSuperObject.Create('{}');
  json.S['slide']:= '1';

  for  i:= 0 to Dest.Count-1 do
    begin
      if rects[i].Tag = 1 then
        begin
          json.A['selected'].S[j]:= IntToStr(i+1);
          Inc(j);

        end;
    end;

  req.Method:= TRESTRequestMethod.rmPOST;
  req.AddBody(json.AsJSON(true), ctAPPLICATION_JSON);
  req.Execute;
end;
我可以作为参数发送,如:

app.post('/api/db', function(req, res){
    console.log(req.body);
});

但我不知道发送json是真的,因为当我这样发送时,它是作为字符串发送的。但我想以json类型发送。但我不能。有人能帮我吗

您的问题是什么?我如何修复问题顶部的代码?如果您想使用接受TJSONObject的重载,您需要使用内置的Delphi JSON支持,因为我认为SuperObject库不能强制转换为TJSONObject对象。在所有情况下,TJSONObject!=ISuperObject。当然也只支持TJSONObject。你说的JSON格式是什么意思?你似乎认为JSON不是文本,其实不然。JSON只是文本。
req.AddParameter('JSON', json.AsJSON(true));