Skip to content

Make it easier to get json property values #28588

@Tratcher

Description

@Tratcher

RE: dotnet/aspnetcore#7105 (comment)

Newtonsoft JObject .Value<string>(propertyName); as a convenient way to find a property and extract the value in a single operation. Note this returns null of the property isn't found. It also type converts the various datatypes to strings if that's the T you requested.

The equivalent code for JsonDocument looks something like this:

document.RootElement.TryGetProperty(key, out var value) ? value.ToString() : null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions