BaaS Kinvey SignupUser的JSON UserData格式

时间:2014-10-31 08:51:08

标签: json delphi c++builder kinvey mbaas

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

0 个答案:

没有答案