当前位置: 首页>>代码示例>>C#>>正文


C# JSONObject.ToString方法代码示例

本文整理汇总了C#中JSONObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.ToString方法的具体用法?C# JSONObject.ToString怎么用?C# JSONObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSONObject的用法示例。


在下文中一共展示了JSONObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostData

    IEnumerator PostData(JSONObject json)
    {
        //WWWForm testWWW = new WWWForm();
        //testWWW.AddField("Score","12");
        //testWWW.AddField("ContentKey","91FA1062-255B-40FB-A108-3FA783BFF6CD");
        //testWWW.AddField("Level","31");
        //testWWW.AddField("User","0980808A-2AFC-411D-96A5-009487091A61");
        //testWWW.AddField("Date","2014-06-06 00,00,00Z");
        //testWWW.AddField("Powerbar","21");
        //WWW www = new WWW(url, testWWW);

        //string input = @"{""Date"":""" + System.DateTime.Now.ToString("mm/dd/yyyyTHH:mm:ss") [email protected]"""}";
        Hashtable headers = new Hashtable();
        headers.Add("Content-Type", "application/json");

        print("Exact Json: \n" + json.ToString(true));
        byte[] body = System.Text.Encoding.UTF8.GetBytes(json.ToString());
        WWW www = new WWW(url, body, headers);
        
        yield return www;
        if (www.error != null)
        {
            print("Platform posting - SUCCESS");
        }
    }
开发者ID:vorrin,项目名称:store-game,代码行数:25,代码来源:God.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        JSONObject configJSON = new JSONObject();
        JSONObject j = new JSONObject();
        JSONObject platforms = new JSONObject(JSONObject.Type.ARRAY);
        string thisDirectory = Directory.GetCurrentDirectory();
        bool platformDirectory = false;

        browser = browserContainer.GetComponent<Browser>();

        DirectoryInfo dir = new DirectoryInfo(thisDirectory + @"\Platforms");

        try {
            if (dir.Exists) {
                platformDirectory = true;
            } else {
                dir.Create();
                platformDirectory = true;
            }
        } catch (Exception e) {
            platformDirectory = false;
            Debug.Log(e);
        }

        if (platformDirectory) {
            FileInfo[] info = dir.GetFiles("*.png");
            platformTextures = new Texture2D[info.Length];
            platformNames = new string[info.Length];
            platformIdentities = new int[info.Length][];

            configJSON.AddField("player", "Bloodyaugust");
            configJSON.AddField("platforms", platforms);

            int i = 0;
            foreach (FileInfo f in info) {
                j = new JSONObject();
                WWW currentTexture = new WWW("file:///" + f);

                platformTextures[i] = currentTexture.texture;
                platformNames[i] = Path.GetFileNameWithoutExtension(f + "");
                platformIdentities[i] = TextureToIdentity(platformTextures[i]);

                platforms.Add(j);
                j.AddField("name", platformNames[i]);
                j.AddField("value", i.ToString());

                Debug.Log(Path.GetFileNameWithoutExtension(f + ""));

                i++;
            }

            browser.CallFunction("Messaging.trigger", "platforms", configJSON.ToString());
            Debug.Log(configJSON.ToString());
        }
    }
开发者ID:Bloodyaugust,项目名称:missilewarunity,代码行数:56,代码来源:ConfigHandler.cs

示例3: SaveToKeyChain

  public static void SaveToKeyChain(string keyName, string mValue) {
    #if UNITY_IPHONE
      if (Application.platform == RuntimePlatform.IPhonePlayer) {
        KeyChainBindings.SetStringForKey(keyName, mValue);
      }
		#endif
		#if UNITY_ANDROID
      if (Application.platform == RuntimePlatform.Android) {
        AndroidTools.SharedPreferencesSet(keyName, mValue);
      }
		#endif
		#if UNITY_EDITOR
		  string filePath = Path.Combine(Application.persistentDataPath, LOCAL_KEYCHAIN_FILE);
		  JSONObject data;
		  if (File.Exists(filePath)) {
  			string readText = File.ReadAllText(filePath);
  			data = JSONObject.Parse(readText);
  			data.Add(keyName, mValue);
  			File.WriteAllText(filePath, data.ToString());
  		} else {
  		  data = new JSONObject();
  		  data.Add(keyName, mValue);
  		  File.WriteAllText(filePath, data.ToString());
  		}
    #endif
  }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:26,代码来源:FileManager.cs

示例4: 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();

        });
    }
开发者ID:chris-chris,项目名称:Chapter22,代码行数:35,代码来源:RankSingleton.cs

示例5: RequestFunction

 private void RequestFunction(string function, JSONObject data, Action<bool, string> callback)
 {
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.parse.com/1/functions/" + function);
     string postData = data.ToString();
     byte[] byteData = Encoding.ASCII.GetBytes(postData);
     request.ContentType = "application/json";
     request.ContentLength = byteData.Length;
     request.Method = "POST";
     request.Headers.Add("X-Parse-Application-Id", parseApplicationID);
     request.Headers.Add("X-Parse-REST-API-Key", parseRestAPIKey);
     request.Credentials = CredentialCache.DefaultCredentials;
     using (Stream stream = request.GetRequestStream()) { stream.Write(byteData, 0, byteData.Length); }
     try
     {
         request.BeginGetResponse(new AsyncCallback(delegate(IAsyncResult result)
         {
             HttpWebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result) as HttpWebResponse;
             using (Stream stream = response.GetResponseStream())
             {
                 StreamReader reader = new StreamReader(stream);
                 if (callback != null) callback(true, reader.ReadToEnd());
                 reader.Close();
                 response.Close();
             }
         }), request);
     }
     catch (Exception e)
     {
         Debug.Log(string.Format("Exception Cached: {0}|{1}", e.Source, e.Message));
         if (callback != null) callback(false, e.Message);
     }
 }
开发者ID:LuviKunG,项目名称:LuviTools,代码行数:32,代码来源:LuviParse.cs

示例6: OnGUI

    void OnGUI()
    {
        JSON = EditorGUILayout.TextArea(JSON);
        GUI.enabled = !string.IsNullOrEmpty(JSON);
        if(GUILayout.Button("Check JSON")) {
        #if PERFTEST
            Profiler.BeginSample("JSONParse");
            j = JSONObject.Create(JSON);
            Profiler.EndSample();
            Profiler.BeginSample("JSONStringify");
            j.ToString(true);
            Profiler.EndSample();
        #else
            j = JSONObject.Create(JSON);
        #endif
            Debug.Log(j.ToString(true));
        }
        if(j) {
            //Debug.Log(System.GC.GetTotalMemory(false) + "");
            if(j.type == JSONObject.Type.NULL)
                GUILayout.Label("JSON fail:\n" + j.ToString(true));
            else
                GUILayout.Label("JSON success:\n" + j.ToString(true));

        }
    }
开发者ID:OpenSorceress,项目名称:meta_drone,代码行数:26,代码来源:JSONChecker.cs

示例7: BuildManifest

        public static void BuildManifest()
        {
            JSONObject json = new JSONObject(JSONObject.Type.ARRAY);
            string[] levels = Directory.GetFiles(Application.dataPath + "/Levels_Exported/", "*.json");

            for (int i = 0; i < levels.Length; i++) {
                JSONObject data = new JSONObject(JSONObject.Type.OBJECT);
                string fileContents = File.ReadAllText(levels[i]);
                string hash = LevelManagementUtils.Hash(fileContents);
                data.AddField("Hash", hash);
                string url = levels[i].Replace(Application.dataPath, "http://podshot.github.io/TwoTogether" /*"http://127.0.0.1:8000/"*/);
                url = url.Replace("_Exported", "");
                data.AddField("URL", url);
                data.AddField("Name", levels[i].Replace(Application.dataPath + "/Levels_Exported/", ""));

                JSONObject thumb = new JSONObject(JSONObject.Type.OBJECT);
                thumb.AddField("URL", "http://podshot.github.io/TwoTogether/Thumbnails/" + levels[i].Replace(Application.dataPath + "/Levels_Exported/", "").Replace(".json", ".png"));
                thumb.AddField("Name", levels[i].Replace(Application.dataPath + "/Levels_Exported/", "").Replace(".json", ".png"));

                data.AddField("Thumbnail", thumb);
                json.Add(data);
            }

            TextWriter writer = new StreamWriter(Application.dataPath + "/Levels_Exported/levels_.manifest");
            writer.WriteLine(json.ToString(true));
            writer.Close();
            Debug.Log("Wrote manifest file");
        }
开发者ID:Podshot,项目名称:TwoTogether,代码行数:28,代码来源:BuildLevelManifest.cs

示例8: JoinLobby

 public void JoinLobby(int size)
 {
     JSONObject data = new JSONObject();
     data.AddField("size", size);
     Debug.Log("Join Lobby " + data.ToString());
     sendRequest(ServerAPI.RequestType.JoinLobby, data);
 }
开发者ID:LeagueOfDevelopers,项目名称:Imaginarium,代码行数:7,代码来源:ServerDriver.cs

示例9: CreatePublicMessageObject

 private ISFSObject CreatePublicMessageObject(JSONObject jsonData, string commandId) {
   ISFSObject objOut = new SFSObject();
   objOut.PutByteArray("jsonData", Utils.ToByteArray(jsonData.ToString()));
   objOut.PutUtfString("message", jsonData.GetString("message"));
   objOut.PutUtfString("cmd", commandId);
   return objOut;
 }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:7,代码来源:GameBottomBarScript.cs

示例10: Post

	public virtual void Post(string url, Dictionary<string, string> data, System.Action<HttpResult> onResult) {
	
		this.MakeRequest(url, HttpMethods.POST, onResult, (r) => {

			JSONObject js = new JSONObject(data);
			var requestPayload = js.ToString();

			UTF8Encoding encoding = new UTF8Encoding();
			r.ContentLength = encoding.GetByteCount(requestPayload);
			r.Credentials = CredentialCache.DefaultCredentials;
			r.Accept = "application/json";
			r.ContentType = "application/json";
			
			//Write the payload to the request body.
			using ( Stream requestStream = r.GetRequestStream())
			{
				requestStream.Write(encoding.GetBytes(requestPayload), 0,
				                    encoding.GetByteCount(requestPayload));
			}

			return false;

		});

	}
开发者ID:amanita-main,项目名称:Unity3d.UI.Windows,代码行数:25,代码来源:HttpRequest.cs

示例11: GetRoomStatus

 public void GetRoomStatus()
 {
     JSONObject data = new JSONObject();
     Prefs pref = new Prefs();
     data.AddField("token", pref.getToken());
     Debug.Log("GetRoomStatus" + data.ToString());
     sendRequest(ServerAPI.RequestType.GetGameStatus, data);
 }
开发者ID:LeagueOfDevelopers,项目名称:Imaginarium,代码行数:8,代码来源:ServerDriver.cs

示例12: DataCallBack

	private void DataCallBack (JSONObject result)
	{	
		Debug.Log ("Result " + result.ToString ());
		id.text = "id " + result.GetField ("userid").ToString (); 
		name.text = "name " + result.GetField ("name").ToString ();
		username.text = "username " + result.GetField ("username").ToString ();
		position.text = "position " + result.GetField ("position").ToString ();
	}
开发者ID:nattayamairittha,项目名称:webapi_unity3d,代码行数:8,代码来源:GameController.cs

示例13: UpdateLobby

 public void UpdateLobby()
 {
     JSONObject data = new JSONObject();
     Prefs pref = new Prefs();
     data.AddField("token", pref.getToken());
     Debug.Log("Update Lobby" + data.ToString());
     sendRequest(ServerAPI.RequestType.UpdateLobby, data);
 }
开发者ID:LeagueOfDevelopers,项目名称:Imaginarium,代码行数:8,代码来源:ServerDriver.cs

示例14: ParseTo

    public string ParseTo(Dictionary<string, string> data)
    {
        string rawdata = string.Empty;

        JSONObject jsonObj = new JSONObject(data);
        rawdata = jsonObj.ToString();

        return rawdata;
    }
开发者ID:rmarx,项目名称:ReverseRPG,代码行数:9,代码来源:LugusConfigDataHelper.cs

示例15: JsonThreadCallback

 void JsonThreadCallback(System.Object stateInfo)
 {
     SocketListener.start(listenPort, (writer, line) => {
         var json = new JSONObject(line);
         Debug.Log("Request : " + json.ToString());
         writer.WriteLine("Server reqponse");
         writer.Flush();
     });
 }
开发者ID:nobnak,项目名称:JsonUnityServer,代码行数:9,代码来源:Server.cs


注:本文中的JSONObject.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。