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


C# JsonWriter.ToString方法代码示例

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


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

示例1: PostTest1

    IEnumerator PostTest1()
    {
        string str = @"";
        // string like this
        // str = @"{""Id"":0,""IMEI"":""String"",""Phone"":""String"",""Name"":""String"",""Status"":0,""CreateTime"":""\/Date(-62135596800000+0800)\/"",""UpdateTime"":""\/Date(-62135596800000+0800)\/""}";
        // write Json
        JsonWriter writer = new JsonWriter();
        writer.WriteObjectStart();
        writer.WritePropertyName("Id");
        writer.Write(0);
        writer.WritePropertyName("IMEI");
        writer.Write("7654321");
        writer.WritePropertyName("Phone");
        writer.Write("13802817183");
        writer.WritePropertyName("Name");
        writer.Write("bbzm");
        writer.WritePropertyName("Status");
        writer.Write("1");
        writer.WritePropertyName("CreateTime");
        writer.Write("2013-01-01");
        writer.WritePropertyName("UpdateTime");
        writer.Write("2013-10-10");
        writer.WriteObjectEnd();
        str = writer.ToString();

        Debug.Log(str);
        WWWForm parameter = new WWWForm();
        parameter.AddField("Body", str);

        WWW postRequest = new WWW(@"http://192.168.133.225:82/Client/123456?format=json", parameter);
        yield return postRequest;

        JsonReader read = new JsonReader(postRequest.text);
        Debug.Log(postRequest.text);
        Debug.Log(" ----------------- ");
        while (read.Read())
        {
            Debug.Log(read.Token + " : " + read.Value + " : " + read.GetType().ToString());
        }
        Debug.Log(" ----------------- ");
    }
开发者ID:bbknightzm,项目名称:unitySample,代码行数:41,代码来源:HttpPostTest.cs

示例2: getJsonString

    public string getJsonString(object obj)
    {
        logMessage("object="+obj);

        //serialization
        JsonWriter writer = new JsonWriter();
        writer.PrettyPrint = true;
        JsonMapper.ToJson(obj,writer);

        string json = writer.ToString();
        logMessage("json="+json);
        return json;
    }
开发者ID:rLeblancTemp,项目名称:ProjetZero3,代码行数:13,代码来源:RedMetricsManager.cs

示例3: getJsonString

 public string getJsonString (object obj)
 {
     //serialization
     JsonWriter writer = new JsonWriter ();
     writer.PrettyPrint = true;    
     JsonMapper.ToJson (obj, writer);    
 
     string json = writer.ToString ();
     return json;
 }
开发者ID:CyberCRI,项目名称:Hero.Coli,代码行数:10,代码来源:RedMetricsManager.cs

示例4: writeConfig

	private static void writeConfig() {
		JsonWriter cfg = new JsonWriter();
		cfg.WriteObjectStart();
		cfg.WritePropertyName("scene");
		cfg.WriteArrayStart();
		GameObject[] arr = Selection.gameObjects;
		foreach (GameObject obj in arr) {
			writeObject(obj, ref cfg);
		}
		cfg.WriteArrayEnd();
		cfg.WriteObjectEnd();

		string filepath = folderName + "/scene.lightmap";
		if (File.Exists(filepath)) {
			File.Delete(filepath);
		}
		FileStream fs = new FileStream(filepath, FileMode.Create);
		BinaryWriter bw = new BinaryWriter(fs);
		bw.Write(cfg.ToString().ToCharArray());
		bw.Close();
		fs.Close();
		Debug.Log("Write Config:" + filepath);
	}
开发者ID:helojo,项目名称:Monkey,代码行数:23,代码来源:LightmapPlugin.cs

示例5: ToJson

 private static string ToJson(object obj)
 {
     var jsonWriter = new JsonWriter { LowerCaseProperties = true };
     JsonMapper.ToJson(obj, jsonWriter);
     return jsonWriter.ToString();
 }
开发者ID:RLittlesII,项目名称:Cake.Slack,代码行数:6,代码来源:SlackChatApi.cs

示例6: Start

    void Start()
    {
        ExampleSerializedClass serializedClass = new ExampleSerializedClass();

        JsonWriter writer = new JsonWriter();
        writer.PrettyPrint = true;

        JsonMapper.ToJson(serializedClass,writer);

        string json = writer.ToString();
        Debug.Log(json);

        // If you don't need a JsonWriter, use this.
        //string json = JsonMapper.ToJson(exampleClass);

        ExampleSerializedClass deserializedClass = JsonMapper.ToObject<ExampleSerializedClass>(savedJsonString);

        Debug.Log(deserializedClass.myString);
    }
开发者ID:SNUGDC,项目名称:Killing-Game,代码行数:19,代码来源:JsonExample.cs


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