public void Item_Set_Get() { JsonArray array = new JsonArray(new JsonPrimitive(true)); JsonPrimitive value = new JsonPrimitive(false); array[0] = value; Assert.Same(value, array[0]); }
public void ImplicitCast_Decimal() { JsonPrimitive primitive = new JsonPrimitive(1m); decimal toPrimitive = primitive; Assert.Equal(1m, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Guid() { JsonPrimitive primitive = new JsonPrimitive(new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); Guid toPrimitive = primitive; Assert.Equal(new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_TimeSpan() { JsonPrimitive primitive = new JsonPrimitive(TimeSpan.Zero); TimeSpan toPrimitive = primitive; Assert.Equal(TimeSpan.Zero, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_DateTimeOffset() { JsonPrimitive primitive = new JsonPrimitive(DateTimeOffset.MinValue); DateTimeOffset toPrimitive = primitive; Assert.Equal(DateTimeOffset.MinValue, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_UInt() { JsonPrimitive primitive = new JsonPrimitive(1); uint toPrimitive = primitive; Assert.Equal((uint)1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_String(string value) { JsonPrimitive primitive = new JsonPrimitive(value); string toPrimitive = primitive; Assert.Equal(value, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Float() { JsonPrimitive primitive = new JsonPrimitive(1); float toPrimitive = primitive; Assert.Equal(1.0f, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Double() { JsonPrimitive primitive = new JsonPrimitive(1); double toPrimitive = primitive; Assert.Equal(1.0, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
private static JsonValue CreatePrimitive(object value) { JsonPrimitive jsonPrimitive; if (JsonPrimitive.TryCreate(value, out jsonPrimitive)) { return(jsonPrimitive); } return(null); }
public void ImplicitCast_Long() { JsonPrimitive primitive = new JsonPrimitive(1); long toPrimitive = primitive; Assert.Equal(1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Short() { JsonPrimitive primitive = new JsonPrimitive(1); short toPrimitive = primitive; Assert.Equal(1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
internal override JsonPrimitive ExecuteE(JsonPrimitive jp, JsonValue json, JsonValue parent) { if (Value[0] == '$') { return(new JsonPrimitive(IO.BareValue(WokeJ.GetElementByKey(json, Value.Substring(1))))); } else { return(new JsonPrimitive(Value)); } }
public void ImplicitCast_Bool() { JsonPrimitive primitive = new JsonPrimitive(true); bool toPrimitive = primitive; Assert.True(toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Uri() { JsonPrimitive primitive = new JsonPrimitive(new Uri("scheme://host/")); Uri toPrimitive = primitive; Assert.Equal(new Uri("scheme://host/"), toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
/// <summary>Compares two <see cref="JsonPrimitive"/> instances returning wether one is equal to another.</summary> public bool Equals(JsonPrimitive primitiveA, JsonPrimitive primitiveB) { if (ReferenceEquals(primitiveA, primitiveB)) { return(true); } if (ReferenceEquals(primitiveA, null) || ReferenceEquals(null, primitiveB)) { return(false); } return(Equals(primitiveA.Value, primitiveB.Value)); }
public void Item_Set_Get() { JsonObject obj = new JsonObject(); string key = "key"; JsonValue value = new JsonPrimitive(true); obj[key] = value; Assert.Equal(1, obj.Count); Assert.Same(value, obj[key]); }
void AddPrimitive(JsonPrimitive jsonPrimitive) { if (stack.Count == 0) { root = jsonPrimitive; } else { var parentContainer = stack.Peek(); parentContainer.AddChild(jsonPrimitive); } }
internal override JsonPrimitive ExecuteE(JsonPrimitive jp, JsonValue json, JsonValue parent) { if (json == null) { if (Config.Debug) { Console.WriteLine("[ERROR] Cannot rename something outside a dictionary"); } return(jp); } WokeJ.AddKeyValue(json, KeyNew, jp); return(null); }
private void CheckValues(object[] values, JsonType expectedType) { JsonPrimitive target; bool success; foreach (object value in values) { success = JsonPrimitive.TryCreate(value, out target); Assert.IsTrue(success); Assert.IsNotNull(target); Assert.AreEqual(expectedType, target.JsonType); } }
public static string ToJson(WorkflowJsonObject workflowJson) { JsonObject json = new JsonObject(new List <KeyValuePair <string, JsonValue> >()); JsonArray jsonnodes = new JsonArray(new List <JsonValue>()); JsonArray jsonconns = new JsonArray(new List <JsonValue>()); foreach (var node in workflowJson.nodes) { JsonObject jsonNodeVals = new JsonObject(new List <KeyValuePair <string, JsonValue> >()); JsonPrimitive value_id = new JsonPrimitive(node.id); JsonPrimitive value_name = new JsonPrimitive(node.name); JsonPrimitive value_user = new JsonPrimitive(node.user); JsonPrimitive value_role = new JsonPrimitive(node.role); JsonPrimitive value_xpos = new JsonPrimitive(node.xpos); JsonPrimitive value_ypos = new JsonPrimitive(node.ypos); JsonPrimitive value_status = new JsonPrimitive(""); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("id", value_id)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("name", value_name)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("user", value_user)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("role", value_role)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("xpos", value_xpos)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("ypos", value_ypos)); jsonNodeVals.Add(new KeyValuePair <string, JsonValue>("status", value_status)); jsonnodes.Add(jsonNodeVals); } foreach (var conn in workflowJson.connections) { JsonObject jsonConnVals = new JsonObject(new List <KeyValuePair <string, JsonValue> >()); JsonPrimitive value_from = new JsonPrimitive(conn.from); JsonPrimitive value_to = new JsonPrimitive(conn.to); JsonPrimitive value_label = new JsonPrimitive(conn.label); jsonConnVals.Add(new KeyValuePair <string, JsonValue>("from", value_from)); jsonConnVals.Add(new KeyValuePair <string, JsonValue>("to", value_to)); jsonConnVals.Add(new KeyValuePair <string, JsonValue>("label", value_label)); jsonconns.Add(jsonConnVals); } json.Add(new KeyValuePair <string, JsonValue>("id", workflowJson.id)); json.Add(new KeyValuePair <string, JsonValue>("nodes", jsonnodes)); json.Add(new KeyValuePair <string, JsonValue>("connections", jsonconns)); return(json.ToString()); }
//对象转换,把Json对象转换成普通对象 public static object JsonConvert(this object value, Type type) { if (value == null) { return(null); } if (value is JsonPrimitive) { JsonPrimitive json = (value as JsonPrimitive); if (json.JsonType == JsonType.Number) { //数字行,根据具体C#数据类型转 if (type == typeof(int) || type == typeof(int?)) { return((int)json); } if (type == typeof(double) || type == typeof(double?)) { return((double)json); } if (type == typeof(decimal) || type == typeof(decimal?)) { return((decimal)json); } if (type == typeof(DateTime) || type == typeof(DateTime?)) { // DateTime from1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); DateTime from1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local); DateTime result = from1970.AddMilliseconds((long)json); return(result); } } if (json.JsonType == JsonType.String) { return((string)json); } if (json.JsonType == JsonType.Boolean) { return((bool)json); } } //数字行,根据具体C#数据类型转 if ((type == typeof(int) || type == typeof(int?)) || (type == typeof(double) || type == typeof(double?)) || (type == typeof(decimal) || type == typeof(decimal?))) { return(decimal.Parse(value + "")); } return(value); }
public void ValidJsonObjectDateTimeOffsetRoundTrip() { int seed = 1; Log.Info("Seed: {0}", seed); Random rndGen = new Random(seed); JsonPrimitive sourceJson = new JsonPrimitive(PrimitiveCreator.CreateInstanceOfDateTimeOffset(rndGen)); JsonPrimitive newJson = (JsonPrimitive)JsonValue.Parse(sourceJson.ToString()); if (!JsonValueVerifier.Compare(sourceJson, newJson)) { Assert.Fail("Test failed! The new JsonObject DateTimeOffset value does not equal to the original one."); } }
public void ValueTest() { object[] values = { AnyInstance.AnyInt, AnyInstance.AnyString, AnyInstance.AnyGuid, AnyInstance.AnyDecimal, AnyInstance.AnyBool, AnyInstance.AnyDateTime }; foreach (object value in values) { JsonPrimitive jp; bool success = JsonPrimitive.TryCreate(value, out jp); Assert.IsTrue(success); Assert.AreEqual(value, jp.Value); } }
public void ToString_Null_WorksDependingOnOverload() { JsonPrimitive primitive = new JsonPrimitive((string)null); Assert.Equal("\"\"", primitive.ToString()); using (StringWriter textWriter = new StringWriter()) { primitive.Save(textWriter); Assert.Equal("\"\"", textWriter.ToString()); } using (MemoryStream stream = new MemoryStream()) { Assert.Throws<NullReferenceException>(() => primitive.Save(stream)); } }
public void ToString_Null_WorksDependingOnOverload() { JsonPrimitive primitive = new JsonPrimitive((string)null); Assert.Equal("\"\"", primitive.ToString()); using (StringWriter textWriter = new StringWriter()) { primitive.Save(textWriter); Assert.Equal("\"\"", textWriter.ToString()); } using (MemoryStream stream = new MemoryStream()) { Assert.Throws<NullReferenceException>(() => primitive.Save(stream)); } }
public void BindUnaryOperationTest() { JsonValue value; DynamicMetaObject target; value = new JsonPrimitive(AnyInstance.AnyInt); target = GetJsonValueDynamicMetaObject(value); TestUnaryOperationBinder.TestBindParams(target); TestUnaryOperationBinder.TestMetaObject(target, TestUnaryOperationBinder.NumberOperations); value = new JsonPrimitive(AnyInstance.AnyBool); target = GetJsonValueDynamicMetaObject(value); TestUnaryOperationBinder.TestMetaObject(target, TestUnaryOperationBinder.BooleanOperations); }
private static bool _assign(JsonValue old, JsonValue json, JsonValue parent, string key, string value) { if (String.IsNullOrEmpty(value)) { return(false); } if (old != null && old is JsonPrimitive oldP) { var oldVal = IO.BareValue(oldP); json[key] = new JsonPrimitive(value); return(oldVal != value); } else { json[key] = new JsonPrimitive(value); return(true); } }
public void ReadAsTest() { JsonValue target = new JsonPrimitive(AnyInstance.AnyInt); Assert.AreEqual(AnyInstance.AnyInt.ToString(CultureInfo.InvariantCulture), target.ReadAs(typeof(string))); Assert.AreEqual(AnyInstance.AnyInt.ToString(CultureInfo.InvariantCulture), target.ReadAs <string>()); object value; double dblValue; Assert.IsTrue(target.TryReadAs(typeof(double), out value)); Assert.IsTrue(target.TryReadAs <double>(out dblValue)); Assert.AreEqual(Convert.ToDouble(AnyInstance.AnyInt, CultureInfo.InvariantCulture), (double)value); Assert.AreEqual(Convert.ToDouble(AnyInstance.AnyInt, CultureInfo.InvariantCulture), dblValue); Assert.IsFalse(target.TryReadAs(typeof(Guid), out value), "TryReadAs should have failed to read a double as a Guid"); Assert.IsNull(value, "expected from failed TryReadAs should be null!"); }
internal override bool ExecuteB(JsonObject json, JsonObject parent) { bool changed = false; foreach (var k in json.Keys.ToList()) { if (json[k] is JsonPrimitive jp) { var s = jp.ToString(); if (s.Length < 3 || s[0] != '"' || s[s.Length - 1] != '"') { continue; } s = s.Substring(1, s.Length - 2); if (k == "journal" && s.Length < 10) { Console.WriteLine($"Strange journal name in {json["title"]} : '{s}'"); } if (k == "booktitle" && s.Length < 10) { Console.WriteLine($"Strange book name in {json["title"]} : '{s}'"); } if (Int32.TryParse(s, out int n)) { json[k] = new JsonPrimitive(n); changed = true; } else if (k == "booktitle" && s.Length > 5) { foreach (var wrong in Constants.Numerals.Keys) { if (s.IndexOf(wrong) > 0) { json[k] = new JsonPrimitive(s.Replace(wrong, Constants.Numerals[wrong])); changed = true; break; } } } } } return(changed); }
public void TryCreateInvalidTest() { bool success; JsonPrimitive target; object[] values = { AnyInstance.AnyJsonArray, AnyInstance.AnyJsonObject, AnyInstance.AnyJsonPrimitive, null, AnyInstance.DefaultJsonValue, AnyInstance.AnyDynamic, AnyInstance.AnyAddress, AnyInstance.AnyPerson }; foreach (object value in values) { success = JsonPrimitive.TryCreate(value, out target); Assert.IsFalse(success); Assert.IsNull(target); } }
public void NonNumberToNumberConversionTest() { Assert.AreEqual(1, new JsonPrimitive('1').ReadAs <int>()); Assert.AreEqual <byte>(AnyInstance.AnyByte, new JsonPrimitive(AnyInstance.AnyByte.ToString(CultureInfo.InvariantCulture)).ReadAs <byte>()); Assert.AreEqual <sbyte>(AnyInstance.AnySByte, (sbyte)(new JsonPrimitive(AnyInstance.AnySByte.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <short>(AnyInstance.AnyShort, (short)(new JsonPrimitive(AnyInstance.AnyShort.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <ushort>(AnyInstance.AnyUShort, new JsonPrimitive(AnyInstance.AnyUShort.ToString(CultureInfo.InvariantCulture)).ReadAs <ushort>()); Assert.AreEqual <int>(AnyInstance.AnyInt, new JsonPrimitive(AnyInstance.AnyInt.ToString(CultureInfo.InvariantCulture)).ReadAs <int>()); Assert.AreEqual <uint>(AnyInstance.AnyUInt, (uint)(new JsonPrimitive(AnyInstance.AnyUInt.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <long>(AnyInstance.AnyLong, (long)(new JsonPrimitive(AnyInstance.AnyLong.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <ulong>(AnyInstance.AnyULong, new JsonPrimitive(AnyInstance.AnyULong.ToString(CultureInfo.InvariantCulture)).ReadAs <ulong>()); Assert.AreEqual <decimal>(AnyInstance.AnyDecimal, (decimal)(new JsonPrimitive(AnyInstance.AnyDecimal.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <float>(AnyInstance.AnyFloat, new JsonPrimitive(AnyInstance.AnyFloat.ToString(CultureInfo.InvariantCulture)).ReadAs <float>()); Assert.AreEqual <double>(AnyInstance.AnyDouble, (double)(new JsonPrimitive(AnyInstance.AnyDouble.ToString(CultureInfo.InvariantCulture)))); Assert.AreEqual <byte>(Convert.ToByte(1.23, CultureInfo.InvariantCulture), new JsonPrimitive("1.23").ReadAs <byte>()); Assert.AreEqual <int>(Convert.ToInt32(12345.6789, CultureInfo.InvariantCulture), new JsonPrimitive("12345.6789").ReadAs <int>()); Assert.AreEqual <short>(Convert.ToInt16(1.23e2), (short)new JsonPrimitive("1.23e2")); Assert.AreEqual <float>(Convert.ToSingle(1.23e40), (float)new JsonPrimitive("1.23e40")); Assert.AreEqual <float>(Convert.ToSingle(1.23e-38), (float)new JsonPrimitive("1.23e-38")); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyBool).ReadAs <sbyte>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyBool).ReadAs <short>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyBool).ReadAs <uint>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyBool).ReadAs <long>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyBool).ReadAs <double>(); }); ExceptionTestHelper.ExpectException <FormatException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyUri).ReadAs <int>(); }); ExceptionTestHelper.ExpectException <FormatException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyDateTime).ReadAs <float>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (decimal)(new JsonPrimitive('c')); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (byte)(new JsonPrimitive("0xFF")); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (sbyte)(new JsonPrimitive(AnyInstance.AnyDateTimeOffset)); }); ExceptionTestHelper.ExpectException <FormatException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyUri).ReadAs <uint>(); }); ExceptionTestHelper.ExpectException <FormatException>(delegate { var n = new JsonPrimitive(AnyInstance.AnyDateTime).ReadAs <double>(); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (long)(new JsonPrimitive('c')); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (ulong)(new JsonPrimitive("0xFF")); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (short)(new JsonPrimitive(AnyInstance.AnyDateTimeOffset)); }); ExceptionTestHelper.ExpectException <InvalidCastException>(delegate { var n = (ushort)(new JsonPrimitive('c')); }); ExceptionTestHelper.ExpectException <OverflowException>(delegate { int i = (int)new JsonPrimitive((1L << 32).ToString(CultureInfo.InvariantCulture)); }); ExceptionTestHelper.ExpectException <OverflowException>(delegate { byte b = (byte)new JsonPrimitive("-1"); }); }
public void Insert() { JsonArray array = new JsonArray(new JsonPrimitive(true)); JsonPrimitive value = new JsonPrimitive(false); array.Insert(1, value); Assert.Equal(2, array.Count); Assert.Same(value, array[1]); }
public void Item_Set_Get() { JsonObject obj = new JsonObject(); string key = "key"; JsonValue value = new JsonPrimitive(true); obj[key] = value; Assert.Equal(1, obj.Count); Assert.Same(value, obj[key]); }
public void ImplicitCast_Decimal() { JsonPrimitive primitive = new JsonPrimitive(1m); decimal toPrimitive = primitive; Assert.Equal(1m, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void JsonPrimitive_Roundtrip_ValidUnicode(string str) { string json = new JsonPrimitive(str).ToString(); new UTF8Encoding(false, true).GetBytes(json); Assert.Equal(str, JsonValue.Parse(json)); }
public void ImplicitCast_UShort() { JsonPrimitive primitive = new JsonPrimitive(1); ushort toPrimitive = primitive; Assert.Equal((ushort)1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Double() { JsonPrimitive primitive = new JsonPrimitive(1); double toPrimitive = primitive; Assert.Equal(1.0, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_SByte() { JsonPrimitive primitive = new JsonPrimitive(1); sbyte toPrimitive = primitive; Assert.Equal(1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Int() { JsonPrimitive primitive = new JsonPrimitive(1); int toPrimitive = primitive; Assert.Equal(1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Uri() { JsonPrimitive primitive = new JsonPrimitive(new Uri("scheme://host/")); Uri toPrimitive = primitive; Assert.Equal(new Uri("scheme://host/"), toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_String(string value) { JsonPrimitive primitive = new JsonPrimitive(value); string toPrimitive = primitive; Assert.Equal(value, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Guid() { JsonPrimitive primitive = new JsonPrimitive(new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); Guid toPrimitive = primitive; Assert.Equal(new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_TimeSpan() { JsonPrimitive primitive = new JsonPrimitive(TimeSpan.Zero); TimeSpan toPrimitive = primitive; Assert.Equal(TimeSpan.Zero, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_DateTimeOffset() { JsonPrimitive primitive = new JsonPrimitive(DateTimeOffset.MinValue); DateTimeOffset toPrimitive = primitive; Assert.Equal(DateTimeOffset.MinValue, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void Add() { JsonArray array = new JsonArray(); JsonValue value = new JsonPrimitive(true); array.Add(value); Assert.Equal(1, array.Count); Assert.Same(value, array[0]); }
public void ImplicitCast_Float() { JsonPrimitive primitive = new JsonPrimitive(1); float toPrimitive = primitive; Assert.Equal(1.0f, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_Bool() { JsonPrimitive primitive = new JsonPrimitive(true); bool toPrimitive = primitive; Assert.True(toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }
public void ImplicitCast_ULong() { JsonPrimitive primitive = new JsonPrimitive(1); ulong toPrimitive = primitive; Assert.Equal((ulong)1, toPrimitive); JsonValue fromPrimitive = toPrimitive; Assert.Equal(primitive, toPrimitive); }