public void AsBoolean_with_valid_boolean() { JsonValue jsonValue = JsonValue.NewString("True"); bool result = jsonValue.AsBoolean(); Assert.AreEqual(true, result); }
public static object ConvertJsonValueToObject(JsonValue value) { if (value.IsNull) { return(null); } if (value.IsBoolean) { return(value.AsBoolean()); } if (value.IsFloat || value.IsNumber) { return(value.AsDecimal()); } if (value.IsString) { return(value.AsString()); } if (value.IsArray) { return(value.AsArray().Select(ConvertJsonValueToObject).ToArray()); } if (!value.IsRecord) { throw new NotImplementedException($"There's not implementation for JsonValue tag {value.Tag}"); } var record = (JsonValue.Record)value; return(record.properties.ToDictionary(kvPair => kvPair.Item1, kvPair => ConvertJsonValueToObject(kvPair.Item2))); }