public static class Test
{
public static bool Run()
{
JsonElement# json = JsonElement.Parse("\"foo\""); //FAIL: cl
if (!json.IsString() || json.GetString() != "foo")
return false;
json = JsonElement.Parse("10.5");
if (!json.IsNumber() || json.GetDouble() != 10.5)
return false;
json = JsonElement.Parse("true");
if (!json.IsBoolean() || !json.GetBoolean())
return false;
json = JsonElement.Parse("false");
if (!json.IsBoolean() || json.GetBoolean())
return false;
json = JsonElement.Parse("null");
if (!json.IsNull())
return false;
json = JsonElement.Parse("[ 5, true ]");
if (!json.IsArray())
return false;
List<JsonElement#> list = json.GetArray();
if (list.Count != 2 || list[0].GetDouble() != 5 || !list[1].IsBoolean())
return false;
json = JsonElement.Parse("{ \"foo\": null, \"bar\": 42 }");
if (!json.IsObject())
return false;
Dictionary<string(), JsonElement#> dict = json.GetObject();
if (dict.Count != 2 || !dict["foo"].IsNull() || dict["bar"].GetDouble() != 42)
return false;
return true;
}
}