So when I have a JsonNode I can just ask if it's a JsonObject or a JsonArray and work with those. But when the node is an actual value, how do I know whether it's a string, number or boolean?
Of course I could just try and parse the value, but then a number transmitted in a string would become a number instead of a string which I'd like to avoid.
I'm using System.Text.Json with .NET 6.
From the source, it looks like a JsonValue just wraps a JsonElement. So you can do .GetValue<JsonElement>() (which passes this check), and then inspect its ValueKind property.
Each JsonProperty has two properties - Name and Value of Type JsonElement. JsonElement has an Enum property named ValueKind which can help you determine what of what data type your JSON value is.
You can get JsonProperties by calling .EnumerateObject() on your JsonElement. You can work with your Json document as a JsonElement instead of JsonObject.