使用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;
}
//---------------------------------------------------------------------------