我相信我在这里做错了.我已经跟踪了我在stackoverflow上找到的每个例子,但仍然没有在我的环境中使用它.我想更新我的控件和环境,但我现在已经锁定了我拥有的东西.
我在用:
我需要将此JSON发送到URL:
"auth": {
"applicationId": "appID",
"applicationPassword": "pwd",
"accountId": "acct",
"userId": "dev"
}
Run Code Online (Sandbox Code Playgroud)
这没有什么可怕的,但当我尝试发布我的请求时,我倾向于收到一条消息,请求是优雅地关闭.IDSocketHandle.pas中的CheckIsReadable具有Handleallocated = false.我不确定在配置我的IdHTTP时我做错了什么,但它不起作用.
我已经尝试了所有这些问题和其他几个问题的例子,但这些方法似乎都不适合我:
任何提示将非常感谢.
当前变体如下所示:
procedure Tformmaintestbed.btnJSONSendClick(Sender: TObject);
var
code: Integer;
sResponse: string;
JsonToSend: TStringStream;
begin
JsonToSend := TStringStream.Create(
'{"auth": {"applicationId": "' + edApplication.text +
'","applicationPassword": "' + edpassword.text +
'","accountId": "' + edaccount.text +
'","userId": "' + edUser.text +
'"}}');
try
HTTP1.Request.ContentType := 'application/json';
HTTP1.Request.ContentEncoding := 'utf-8';
memoRequest.lines.clear;
memoRequest.lines.add(JsonToSend); …Run Code Online (Sandbox Code Playgroud) 我收到的回复如下:
{
"successful": true,
"responseMessage": "OK",
"responseCode": 2000,
"messages": [
{
"messageId": "da86ede3-83de-4080-9c20-e8a335a7ac25",
"messageType": "MessageComposeSendNotification",
"queuedDateTime": 1402092032000,
"processAttemptCount": 0,
"processed": false
},
{
"messageId": "382556a3-0654-4a1c-9b54-8393097d9ec9",
"messageType": "RecordFileImport",
"queuedDateTime": 1410811005000,
"processAttemptCount": 1,
"processed": false
}
]
}
Run Code Online (Sandbox Code Playgroud)
js.Field['successful'].value我只需进行调用或其他字段名称就可以很好地访问前三个字段。我现在需要访问该Messages数组。我想做的是逐步完成 中的每个项目Messages。如果是,MessageType我"RecordFileImport"想将其保存MessageID到字符串列表中。
现在我无法访问Messages。我假设我需要创建一个新的tlkJSONObject或可能的 atlkJSONList来访问其内容,但我似乎无法实例化该对象,并且不知道如何浏览这些项目。
我正在使用 Delphi 7 和 LkJSON v1.07。