本文整理汇总了C#中JsonObject.ParseDocument方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.ParseDocument方法的具体用法?C# JsonObject.ParseDocument怎么用?C# JsonObject.ParseDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.ParseDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayAccessToNotArray
public void ArrayAccessToNotArray()
{
JsonObject json = new JsonObject();
json.ParseDocument(input2);
int i = 0;
JsonValue v = json["myArrays"];
Assert.Catch (typeof(JsonValueException), delegate { i = v[1].intValue; } );
Assert.Catch (typeof(JsonValueException), delegate { i = v.array[1].intValue; } );
}
示例2: GetIPAddr
IEnumerator GetIPAddr()
{
string url = serverAddr + "/jsontest/ip.json";
WWW www = new WWW(url);
yield return www;
JsonObject json = new JsonObject();
json.ParseDocument(www.text);
getIpAddrTestSuccess = json["ip"].isString;
}
示例3: GetString
public void GetString()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1.text);
// test direct query
Assert.That ( json.IsString ("name1") );
Assert.That ( json.GetString ("name1").Equals(value1) );
JsonValue jv = json.GetValue("name1");
Assert.That ( jv.isString );
Assert.That ( jv.stringValue.Equals(value1) );
}
示例4: MemberOrderConsistencyParseVsCode
public void MemberOrderConsistencyParseVsCode()
{
JsonObject json = new JsonObject();
JsonObject json2 = new JsonObject();
json.ParseDocument(input1);
json2["member3"] = true;
json2["member2"] = 456.789;
json2["member4"] = false;
json2["member1"] = 123;
json2["member5"] = "hello world again";
Assert.AreEqual(json.ToPrettyString(), json2.ToPrettyString());
}
示例5: ArrayModifyDuringEnumeration
public void ArrayModifyDuringEnumeration()
{
JsonObject json = new JsonObject();
json.ParseDocument(input);
int i = 0;
JsonValue v = json["myArrays"];
i = 0;
foreach(JsonValue item in v) {
Assert.That ( item.intValue == values[i++] );
if(i == 5) {
// modification during enumeration should
// raise InvalidOperationException
v.array.PushBack(99999);
}
}
}
示例6: ArrayIndexAccess
public void ArrayIndexAccess()
{
JsonObject json = new JsonObject();
json.ParseDocument(input);
int i = 0;
JsonValue v = json["myArrays"];
Assert.That ( v.array.Count == values.Length );
for(i=0; i< values.Length; ++i) {
Assert.That ( v[i].intValue == values[i] );
}
i = 0;
foreach(JsonValue item in v) {
Assert.That ( item.intValue == values[i++] );
}
}
示例7: ArrayEnumeration
public void ArrayEnumeration()
{
JsonObject json = new JsonObject();
json.ParseDocument(input);
int i = 0;
JsonValue v = json["myArrays"];
Assert.That ( v.array.Count == values.Length );
i = 0;
foreach(JsonValue item in v) {
Assert.That ( item.intValue == values[i++] );
}
i = 0;
foreach(JsonValue item in v.array) {
Assert.That ( item.intValue == values[i++] );
}
}
示例8: TestDeserialize
public void TestDeserialize()
{
JsonObject json = new JsonObject();
json.ParseDocument(input);
TestClass t = json.Deserialize<TestClass>();
Assert.AreEqual (54321, t.MyProp, "MyProp");
Assert.AreEqual (12345, t.value1, "value1");
Assert.AreEqual (true, t.value2, "value2");
Assert.AreEqual (-1234567812345678L, t.value3, "value3");
Assert.AreEqual (1234567812345678UL, t.value4, "value4");
Assert.AreEqual ("hello, deserializer!",t.value5, "value5");
Assert.AreEqual (314748364, t.value6, "value6");
Assert.AreEqual (32, t.value7, "value7");
Assert.AreEqual (TestClass.Mode.Dowit, t.enumMode1, "enumMode1");
Assert.AreEqual (TestClass.Mode.Go, t.enumMode2, "enumMode2");
Assert.AreEqual (987654, t.object1.MyProp, "object1.MyProp");
Assert.AreEqual (67890, t.object1.value1, "object1.value1");
Assert.AreEqual (false, t.object1.value2, "object1.value2");
Assert.AreEqual (-8765432123456, t.object1.value3, "object1.value3");
Assert.AreEqual (8765432123456, t.object1.value4, "object1.value4");
Assert.AreEqual ("this is object within object, yay!", t.object1.value5, "object1.value5");
Assert.AreEqual (null, t.object2, "object2");
JsonValueArray a = json["array1"].array;
Assert.AreEqual (a.Count, t.array1.Length, "array1.Count");
int i = 0;
foreach(JsonValue v in json["array1"]) {
Assert.AreEqual (v.intValue, t.array1[i++], "array1["+i+"]");
}
}
示例9: IsNotOtherThanString
public void IsNotOtherThanString()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1);
// test direct query
Assert.That ( !json.IsArray ("name1") );
Assert.That ( !json.IsBool ("name1") );
Assert.That ( !json.IsDouble ("name1") );
Assert.That ( !json.IsInt ("name1") );
Assert.That ( !json.IsNull ("name1") );
Assert.That ( !json.IsNumber ("name1") );
Assert.That ( !json.IsObject ("name1") );
JsonValue jv = json.GetValue("name1");
Assert.That ( !jv.isArray );
Assert.That ( !jv.isBool );
Assert.That ( !jv.isDouble );
Assert.That ( !jv.isInt );
Assert.That ( !jv.isNull );
Assert.That ( !jv.isNumber );
Assert.That ( !jv.isObject );
}
示例10: ArrayIndexWrite
public void ArrayIndexWrite()
{
JsonObject json = new JsonObject();
json.ParseDocument(input);
JsonValue v = json["myArrays"];
v[4] = 33333;
for(int i=0; i< values2.Length; ++i) {
Assert.That ( v[i].intValue == values2[i] );
}
}
示例11: Parse
public void Parse()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1);
}
示例12: ParseTwoObject
public void ParseTwoObject()
{
JsonObject json = new JsonObject();
json.ParseDocument(jsonData);
json.ParseDocument("{}");
}
示例13: ParseRandom
public void ParseRandom()
{
JsonObject json = new JsonObject();
json.ParseDocument(@"[
null,
[
null
],
[
[]
]
]");
}
示例14: ParseObjectEmptyArray
public void ParseObjectEmptyArray()
{
JsonObject json = new JsonObject();
json.ParseDocument("{\"Assets\" : []}");
}
示例15: ParseModifyAndToString
public void ParseModifyAndToString()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1);
json.AddMember("category", "INIT");
json.AddMember("data_value","foobar");
JsonValue v = json["name1"];
json["name1"].SetString ("adsjlfajsdlfajsdflajs dsjfjdfajd.");
json["name2"].SetDouble(345.678);
Debug.Log (json.ToPrettyString ());
}