简体   繁体   English

Indy 10服务器:如何发送JSON响应?

[英]Indy 10 server : How to send JSON response?

I am looking for a simple code example, using Data.DBXJSON 's TJSONObject to build a response and return it in AResponseInfo.ContentText . 我正在寻找一个简单的代码示例,使用Data.DBXJSONTJSONObject生成响应并将其返回到AResponseInfo.ContentText

Google does not seem to be my friend today :-( Google似乎今天不是我的朋友:-(

The answer is in Embarcadero's documentation. 答案在Embarcadero的文档中。 There is an example showing how to create and parse JSON strings. 一个示例显示了如何创建和解析JSON字符串。 TJSONObject has a ToString() method, eg: TJSONObject具有ToString()方法,例如:

var
  JSON: TJSONObject;
begin
  ...
  JSON := TJSONObject.Create;
  try
    // populate JSON as needed...
    AResponseInfo.ContentText := JSON.ToString;
  finally
    JSON.Free;
  end;
  ...
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM