本文整理汇总了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(" ----------------- ");
}
示例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;
}
示例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;
}
示例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);
}
示例5: ToJson
private static string ToJson(object obj)
{
var jsonWriter = new JsonWriter { LowerCaseProperties = true };
JsonMapper.ToJson(obj, jsonWriter);
return jsonWriter.ToString();
}
示例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);
}