public static Either TryAsJsonObject()

in tools/code/common/Json.cs [46:79]


    public static Either<string, JsonObject> TryAsJsonObject(this JsonNode? node) =>
        node is JsonObject jsonObject
        ? jsonObject
        : "Node is not a JSON object.";

    public static Either<string, JsonArray> TryAsJsonArray(this JsonNode? node) =>
        node is JsonArray jsonArray
        ? jsonArray
        : "Node is not a JSON array.";

    public static Either<string, JsonValue> TryAsJsonValue(this JsonNode? node) =>
        node is JsonValue jsonValue
        ? jsonValue
        : "Node is not a JSON value.";

    public static Either<string, string> TryAsString(this JsonNode? node) =>
        node.TryAsJsonValue()
            .Bind(jsonValue => jsonValue.TryAsString());

    public static Either<string, Uri> TryAsAbsoluteUri(this JsonNode? node) =>
        node.TryAsJsonValue()
            .Bind(jsonValue => jsonValue.TryAsAbsoluteUri());

    public static Either<string, int> TryAsInt(this JsonNode? node) =>
        node.TryAsJsonValue()
            .Bind(jsonValue => jsonValue.TryAsInt());

    public static Either<string, bool> TryAsBool(this JsonNode? node) =>
        node.TryAsJsonValue()
            .Bind(jsonValue => jsonValue.TryAsBool());
}

public static class JsonArrayExtensions
{