使用TBackEndUsers
mBaaS 组件,为了填充新 Kinvey 用户的_push列,我必须将 JSONObject UserData传递给程序:
BackendUsers1->Users->SignupUser(AUserName, AUserData, AUserData, ACreatedObject);
这是请求的 json 片段:
{
"_push" :
{
"_devicetokens": [
"ffcde6a5918106507a460d9709462f5ba37f70aa76d64fa21a4bfd.........."
]
}
}
这是我使用以下源代码获得的错误 json 片段:
{
"_push" :
{
"_devicetokens" : "[\"ffcde6a5918106507a460d9709462f5ba37f70aa76d64fa21a4bfd..........\"]"
}
}
我做错了什么?
#define TOKENS "ffcde6a5918106507a460d9709462f5ba37f70aa76d64fa21a4bfd.........."
void __fastcall TMainForm::CreateUserButtonClick(TObject *Sender)
{
TBackendEntityValue ACreatedObject;
TJSONObject *JSONObject, *JSONPush;
TJSONPair *Pair, *Pair2;
TJSONArray *Array;
JSONObject = new TJSONObject;
Pair = new TJSONPair("first_name", FirstNameEdit->Text);
JSONObject->AddPair(Pair);
Pair = new TJSONPair("last_name", LastNameEdit->Text);
JSONObject->AddPair(Pair);
Pair = new TJSONPair("email", EMailEdit->Text);
JSONObject->AddPair(Pair);
Array = new TJSONArray;
Array->Add((String) TOKENS);
Pair2 = new TJSONPair("_devicetokens", Array->ToString());
JSONPush = new TJSONObject(Pair2);
Pair = new TJSONPair("_push", JSONPush);
JSONObject->AddPair(Pair);
BackendUsers1->Users->SignupUser(UserIdEdit->Text, PasswordEdit->Text, JSONObject, ACreatedObject);
delete JSONObject;
}
//---------------------------------------------------------------------------