本文整理汇总了C#中JSONObject.Add方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.Add方法的具体用法?C# JSONObject.Add怎么用?C# JSONObject.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONObject
的用法示例。
在下文中一共展示了JSONObject.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFriendRank
public void LoadFriendRank(Action callback)
{
JSONArray friendList = new JSONArray ();
foreach(JSONValue item in UserSingleton.Instance.FriendList){
JSONObject friend = item.Obj;
friendList.Add (friend ["id"]);
}
JSONObject requestBody = new JSONObject ();
requestBody.Add ("UserID", UserSingleton.Instance.UserID);
requestBody.Add ("FriendList", friendList);
HTTPClient.Instance.POST (Singleton.Instance.HOST + "/Rank/Friend", requestBody.ToString(), delegate(WWW www) {
Debug.Log("LoadFriendRank" + www.text);
string response = www.text;
JSONObject obj = JSONObject.Parse(response);
JSONArray arr = obj["Data"].Array;
foreach(JSONValue item in arr){
int rank = (int)item.Obj["Rank"].Number;
if(FriendRank.ContainsKey(rank)){
FriendRank.Remove(rank);
}
FriendRank.Add(rank,item.Obj);
}
callback();
});
}
示例2: Init
public override void Init(object[] data) {
base.Init(data);
List<Buddy> buddyList = SmartfoxClient.Instance.GetBuddyList();
if (buddyList.Count > 0) {
Utils.SetActive(noFriendLabel, false);
EventDelegate.Set(btnSendInvite.onClick, EventSendInvite);
JSONObject friend;
friendList = new JSONArray();
for (int i = 0; i < buddyList.Count; i++) {
friend = new JSONObject();
if (buddyList[i].IsOnline) {
friend.Add("displayName", buddyList[i].GetVariable("displayName").GetStringValue());
friend.Add("cash", (long)buddyList[i].GetVariable("cash").GetDoubleValue());
friend.Add("username", buddyList[i].Name);
friendList.Add(friend);
}
}
InitScrollViewData(friendList);
} else {
// TO DO - dont have friend message
Utils.SetActive(scrollview.gameObject, false);
Utils.SetActive(btnSendInvite.gameObject, false);
Utils.SetActive(noFriendLabel, true);
Debug.Log("----------- DONE HAVE ANY FRIEND ----------------");
}
}
示例3: Create
public void Create() {
TLMBGameConfig gameConfig = TLMBGameConfig.CreateCountGame(10);
JSONObject jsonData = new JSONObject();
jsonData.Add("gameConfig", gameConfig.ToJsonObject());
jsonData.Add("seatIndex", 0);
SmartfoxClient.Instance.HandleServerRequest(CreateExtensionRequest(Command.TLMB.CREATE, jsonData));
}
示例4: JoinRoom
// Join user to game lobby room and join available room
public void JoinRoom(BaseSlotMachineScreen.GameType gameType, string roomName = null) {
PopupManager.Instance.ShowLoadingPopup("LoadingText_JoinRoom");
JSONObject jsonData = new JSONObject();
jsonData.Add("gameType", GetCommandByGameType(gameType));
jsonData.Add("roomName", roomName);
SmartfoxClient.Instance.HandleServerRequest(CreateExtensionRequest(Command.SLOT_MACHINE.SLOT_JOIN_ROOM, jsonData));
}
示例5: Play
public void Play(int betPerLineIndex, int numLines) {
JSONObject jsonData = new JSONObject();
jsonData.Add("betPerLine", betPerLineIndex);
jsonData.Add("numLines", numLines);
jsonData.Add("gameType", GetCommandByGameType(ScreenManager.Instance.CurrentSlotScreen.GetCrtGameType()));
SmartfoxClient.Instance.HandleServerRequest(CreateExtensionRequest(Command.SLOT_MACHINE.SLOT_PLAY, jsonData));
}
示例6: ToJsonObject
public JSONObject ToJsonObject() {
JSONObject jsonData = new JSONObject();
jsonData.Add("type", (int)type);
jsonData.Add("coinPerCard", coinPerCard);
jsonData.Add("firstRankRewardCoin", firstRankRewardCoin);
jsonData.Add("secondRankRewardCoin", secondRankRewardCoin);
return jsonData;
}
示例7: ToJson
public static JSONObject ToJson(this Vector3 vec)
{
var json = new JSONObject(JSONObject.Type.ARRAY);
json.Add(vec.x);
json.Add(vec.y);
json.Add(vec.z);
return json;
}
示例8: ClaimInboxReward
public void ClaimInboxReward(int type, long createdAt, string fromUsername) {
PopupManager.Instance.ShowLoadingPopup("PopupInbox_Claiming", false);
JSONObject data = new JSONObject();
data.Add("username", AccountManager.Instance.username);
data.Add("type", type);
data.Add("createdAt", createdAt);
data.Add("fromUsername", fromUsername);
SmartfoxClient.Instance.HandleServerRequest(CreateExtensionRequest(Command.USER.CLAIM_INBOX_REWARD, "ClaimInboxRewardSuccess", data));
}
示例9: EventRegister
void EventRegister() {
if (usernameInput.value != string.Empty && passwordInput.value != string.Empty && retypePasswordInput.value != string.Empty && displayNameInput.value != string.Empty) {
Debug.Log("EventRegister");
JSONObject jsonData = new JSONObject();
jsonData.Add("username", usernameInput.value);
jsonData.Add("password", passwordInput.value);
jsonData.Add("displayName", displayNameInput.value);
AccountManager.Instance.Register(jsonData);
}
}
示例10: Serialize
public override JSONObject Serialize()
{
JSONObject obj = new JSONObject();
obj.Add(cRanks, Ranks);
obj.Add(cModifier, MiscModifier);
obj.Add(cUntrained, CanBeUsedUntrained);
obj.Add(cClassSkill, ClassSkill);
obj.Add(cAbility, (int)KeyAbility);
return obj;
}
示例11: to_json
public JSONObject to_json()
{
JSONObject rtv = new JSONObject();
rtv.Add(SN.ID,_id);
rtv.Add(SN.PLAYER_ID,_playerid);
rtv.Add(SN.POS,_pos.to_json());
rtv.Add(SN.VEL,_vel.to_json());
rtv.Add(SN.ROT,_rot.to_json());
return rtv;
}
示例12: Init
public override void Init(object[] data) {
base.Init(data);
EventDelegate.Set(tabInvite.onClick, EventTabInvite);
EventDelegate.Set(tabFriends.onClick, EventTabFriends);
// Get list friends from smartfox buddy list
List<Buddy> buddyList = SmartfoxClient.Instance.GetBuddyList();
if (buddyList.Count > 0) {
JSONObject friend;
friendList = new JSONArray();
for (int i = 0; i < buddyList.Count; i++) {
friend = new JSONObject();
if (buddyList[i].IsOnline) {
friend.Add("displayName", buddyList[i].GetVariable("displayName").GetStringValue());
friend.Add("cash", (long)buddyList[i].GetVariable("cash").GetDoubleValue());
friend.Add("avatar", buddyList[i].GetVariable("avatar").GetStringValue());
friend.Add("facebookId", buddyList[i].GetVariable("facebookId").GetStringValue());
} else {
friend.Add("displayName", buddyList[i].GetVariable("$displayName").GetStringValue());
friend.Add("cash", (long)buddyList[i].GetVariable("$cash").GetDoubleValue());
friend.Add("avatar", buddyList[i].ContainsVariable("$avatar") ? buddyList[i].GetVariable("$avatar").GetStringValue() : string.Empty);
friend.Add("facebookId", buddyList[i].ContainsVariable("$facebookId") ? buddyList[i].GetVariable("$facebookId").GetStringValue() : string.Empty);
}
friend.Add("username", buddyList[i].Name);
friendList.Add(friend);
}
InitScrollViewData(friendList);
} else {
Utils.SetActive(scrollview.gameObject, false);
Debug.Log("----------- DONE HAVE ANY FRIEND ----------------");
}
}
示例13: loginWeme
/**
* Weme sdk loginWeme
*
* @param oAuthString -
* @param WmInterfaceBrokerDelegate
*/
public void loginWeme(string clientId,string clientSecret,WmInterfaceBroker.WmInterfaceBrokerDelegate callback){
if(WemeManager.isEmpty(clientId)==true||WemeManager.isEmpty(clientSecret)==true){
Debug.Log("must not null clientId or clientSecret");
return;
}
JSONObject jsonObject = new JSONObject();
jsonObject.Add(JSON_KEY_URI,JSON_VALUE_PREFIX_URI+WM_HOST_WEME);
JSONObject paramsObject = new JSONObject();
paramsObject.Add("clientId",clientId);
paramsObject.Add("clientSecret",clientSecret);
jsonObject.Add(JSON_KEY_PARAMS,paramsObject);
WmInterfaceBroker.getInstance.requestAsync(jsonObject.ToString(),callback);
}
示例14: SendChat
public void SendChat() {
if (chatInput.value != string.Empty) {
string escapedString = Utils.ChatEscape(chatInput.value);
// DisplayBubbleChat(escapedString, currentScreen.FindUserSlot(AccountManager.Instance.username));
JSONObject data = new JSONObject();
data.Add("message", escapedString);
data.Add("senderId", AccountManager.Instance.username);
data.Add("senderName", AccountManager.Instance.displayName);
SmartfoxClient.Instance.HandleServerRequest(CreatePublicMessageRequest(Command.USER.CHAT_IN_ROOM, string.Empty, data));
AddChatToList(data);
chatInput.value = string.Empty;
StartCoroutine(KeepKeyboardOpen());
}
}
示例15: GetDistanceToObject
//Server sending server data to 3d environment
public string GetDistanceToObject()
{
_serializedObject = new JSONObject (JSONObject.Type.OBJECT);
JSONObject trainingCase = new JSONObject(JSONObject.Type.OBJECT);
trainingCase.AddField("scaledSpeed", MoveCar.scaledSpeed);
trainingCase.AddField("scaledForward", scaledForward);
trainingCase.AddField("scaledLeftRightRatio", scaledLRRatio);
_serializedObject.AddField("data", trainingCase);
JSONObject types = new JSONObject(JSONObject.Type.ARRAY);
types.Add ("motion");
types.Add ("steering");
_serializedObject.AddField("types", types);
return _serializedObject.Print ();
}