本文整理汇总了C#中JSONArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# JSONArray.Add方法的具体用法?C# JSONArray.Add怎么用?C# JSONArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitScrollViewData
public void InitScrollViewData(JSONArray mFriendList) {
friendList = mFriendList;
friendListRows = new JSONArray();
JSONObject row = new JSONObject();
for (int i = 0; i < friendList.Length; i++) {
if (Utils.IsOdd(i)) {
row.Add("right", friendList[i].Obj);
friendListRows.Add(row);
} else {
row = new JSONObject();
row.Add("left", friendList[i].Obj);
if (i == friendList.Length - 1) {
friendListRows.Add(row);
}
}
}
isLoading = false;
wrapContent.ResetChildPositions();
scrollview.currentMomentum = Vector3.zero;
scrollview.ResetPosition();
Transform tempGameObject;
wrapContent.minIndex = -(friendListRows.Length - 1);
wrapContent.onInitializeItem = UpdateRowDataOnScroll;
bool canDrag = true;
if (friendListRows.Length <= STOP_DRAG_NUMB_ROW) {
canDrag = false;
backgroundDragScrollView.enabled = false;
} else {
backgroundDragScrollView.enabled = true;
}
for (int i = 0; i < wrapContent.transform.childCount; i++) {
tempGameObject = wrapContent.transform.GetChild(i);
if (!tempGameObject.gameObject.activeSelf) {
Utils.SetActive(tempGameObject.gameObject, true);
}
InviteRowScript tempRowScript = tempGameObject.GetComponent<InviteRowScript>();
tempRowScript.Init(scrollview);
if (canDrag) {
tempRowScript.dragScrollView.enabled = true;
} else {
tempRowScript.dragScrollView.enabled = false;
}
if (i < friendListRows.Length) {
Utils.SetActive(tempGameObject.gameObject, true);
tempRowScript.UpdateRowData(friendListRows[i].Obj);
} else {
Utils.SetActive(tempGameObject.gameObject, false);
}
}
}
示例2: 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();
});
}
示例3: 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 ----------------");
}
}
示例4: 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 ----------------");
}
}
示例5: ExportData
public static JSONArray ExportData(this List<int> list)
{
var json_array = new JSONArray();
foreach (var num in list)
json_array.Add(num);
return json_array;
}
示例6: EventSendInvite
void EventSendInvite() {
if (listInviteUsers.Count > 0) {
JSONArray arr = new JSONArray();
for (int i = 0; i < listInviteUsers.Count; i++) {
arr.Add(listInviteUsers[i]);
}
Debug.Log("EventSendInvite " + arr.ToString());
UserExtensionRequest.Instance.InviteToGame(arr, ScreenManager.Instance.CurrentSlotScreen.GetCrtGameType(), ScreenManager.Instance.CurrentSlotScreen.GetRoomId());
Close();
}
}
示例7: GetJSON
// ================================================================================
// loading and saving
// --------------------------------------------------------------------------------
public JSONObject GetJSON()
{
JSONObject data = new JSONObject();
JSONArray wasUsedArray = new JSONArray();
foreach (var item in wasUsed)
{
wasUsedArray.Add(item);
}
data.Add("wasUsed", wasUsedArray);
return data;
}
示例8: getJSONstr
private void getJSONstr(DataSet ds)
{
string s = base.Request.Params["start"];
string str2 = base.Request.Params["limit"];
JSONObject jsonObject = new JSONObject();
JSONArray array = new JSONArray();
for (int i = int.Parse(s); (i < ds.Tables[0].Rows.Count) && (i < (int.Parse(s) + int.Parse(str2))); i++)
{
JSONObject item = new JSONObject();
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
item.Add(ds.Tables[0].Columns[j].ColumnName, "'" + ds.Tables[0].Rows[i][j] + "'");
}
array.Add(item);
}
jsonObject.Add("totalProperty", ds.Tables[0].Rows.Count);
jsonObject.Add("root", array);
string str3 = JSONConvert.SerializeObject(jsonObject);
base.Response.Write(str3);
}
示例9: SavePlayerData
public void SavePlayerData()
{
JSONArray array = new JSONArray ();
foreach (Player p in players) {
JSONObject player = new JSONObject ();
player.Add ("id", p.Id);
player.Add ("name", p.Name);
JSONArray levels = new JSONArray ();
foreach (LevelData l in p.Levels.Values) {
JSONObject jLevel = new JSONObject ();
jLevel.Add ("id", l.Id);
jLevel.Add ("stepCount", l.StepCount);
levels.Add (jLevel);
}
player.Add ("levels", levels);
array.Add (player);
}
PlayerPrefs.SetString ("players", array.ToString ());
PlayerPrefs.Save ();
}
示例10: ExportData
public JSONValue ExportData()
{
var json_data = new JSONObject();
var anchors_data = new JSONArray();
JSONObject anchor_point_data;
foreach (var anchor_point in m_anchor_points)
{
anchor_point_data = new JSONObject();
anchor_point_data["m_anchor_point"] = anchor_point.m_anchor_point.ExportData();
anchor_point_data["m_handle_point"] = anchor_point.m_handle_point.ExportData();
anchors_data.Add(anchor_point_data);
}
json_data["ANCHORS_DATA"] = anchors_data;
return new JSONValue(json_data);
}
示例11: JSCall
protected void JSCall(string method, params object[] argv)
{
//把参数转换成json
// JSONObject jObj = new JSONObject();
JSONArray param = new JSONArray();
foreach (object o in argv)
{
param.Add(o);
}
//jObj.Add("Cmd", method);
// jObj.Add("Param", argv);
string script = string.Format("{0}({1})", method, JSONConvert.SerializeArray(param));
//使用后台工作线程
BackgroundWorker JSCallWorker = new BackgroundWorker();
JSCallWorker.DoWork += new DoWorkEventHandler(JSCallWorker_DoWork);
JSCallWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(JSCallWorker_RunWorkerCompleted);
m_InvokeQueue.Enqueue(script);
JSCallWorker.RunWorkerAsync();
}
示例12: doApprovalProcess
public void doApprovalProcess(string objectId, string processId, string action, WindowHandler handler)
{
string comment = (action == "Approve") ? "Approved via VRpportunity!" : "Rejected via VRpportunity!";
JSONObject request = new JSONObject();
request.Add ("actionType", action);
request.Add ("contextId", processId);
request.Add ("comments", comment);
JSONArray requestArray = new JSONArray();
requestArray.Add (new JSONValue(request));
JSONObject jsonBody = new JSONObject();
jsonBody.Add ("requests", new JSONValue(requestArray));
string jsonProcess = jsonBody.ToString();
JSONObject chatter = new JSONObject();
chatter.Add ("feedElementType", "FeedItem");
chatter.Add ("subjectId", objectId);
JSONObject chatterBody = new JSONObject();
chatterBody.Add ("type", "Text");
chatterBody.Add ("text", "Approval Process " + comment);
JSONArray segments = new JSONArray();
segments.Add (new JSONValue(chatterBody));
JSONObject chatterSegments = new JSONObject();
chatterSegments.Add ("messageSegments", new JSONValue(segments));
chatter.Add ("body", new JSONValue(chatterSegments));
string jsonChatter = chatter.ToString ();
StartCoroutine(handleApprovalProcess(jsonProcess, jsonChatter, handler));
}
示例13: Update
void Update()
{
if (dummyMessageTimer >= 0) {
if(Mathf.Abs(dummyMessageTimer - Time.time) >= 0.3f) {
string msgJson = "MESG{\"channel_id\": \"0\", \"message\": \"Dummy Text on Editor Mode - " + Time.time + "\", \"user\": {\"image\": \"http://url\", \"name\": \"Sender\"}, \"ts\": 1418979273365, \"scrap_id\": \"\"}";
_OnMessageReceived(msgJson);
dummyMessageTimer = Time.time;
}
}
if (dummyChannelListFlag) {
dummyChannelListFlag = false;
JSONArray channels = new JSONArray();
JSONClass channel = new JSONClass();
channel.Add ("id", new JSONData(1));
channel.Add ("channel_url", new JSONData("app_prefix.channel_url"));
channel.Add ("name", new JSONData("Sample"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(2));
channel.Add ("channel_url", new JSONData("app_prefix.Unity3d"));
channel.Add ("name", new JSONData("Unity3d"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(3));
channel.Add ("channel_url", new JSONData("app_prefix.Lobby"));
channel.Add ("name", new JSONData("Lobby"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(4));
channel.Add ("channel_url", new JSONData("app_prefix.Cocos2d"));
channel.Add ("name", new JSONData("Cocos2d"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(5));
channel.Add ("channel_url", new JSONData("app_prefix.GameInsight"));
channel.Add ("name", new JSONData("GameInsight"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(6));
channel.Add ("channel_url", new JSONData("app_prefix.iOS"));
channel.Add ("name", new JSONData("iOS"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(7));
channel.Add ("channel_url", new JSONData("app_prefix.Android"));
channel.Add ("name", new JSONData("Android"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(8));
channel.Add ("channel_url", new JSONData("app_prefix.News"));
channel.Add ("name", new JSONData("News"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(9));
channel.Add ("channel_url", new JSONData("app_prefix.Lobby"));
channel.Add ("name", new JSONData("Lobby"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
channel.Add ("id", new JSONData(10));
channel.Add ("channel_url", new JSONData("app_prefix.iPad"));
channel.Add ("name", new JSONData("iPad"));
channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
channel.Add ("member_count", new JSONData(999));
channels.Add(channel.ToString());
_OnQueryChannelList(channels.ToString());
}
}
示例14: CharactersJSON
private JSONObject CharactersJSON()
{
JSONObject obj = new JSONObject();
JSONArray array = new JSONArray();
foreach (PlayerCharacter character in mCharacters)
{
JSONArray tempArray = new JSONArray();
tempArray.Add((int)character.Game);
tempArray.Add(character.Serialize());
array.Add(tempArray);
}
obj.Add(SerializableObject.CHARACTER_LIST, array);
return obj;
}
示例15: Add
public override void Add(JSONNode aItem)
{
var tmp = new JSONArray();
tmp.Add(aItem);
Set(tmp);
}