Open
Description
This workaround requires dual lookup if the key is missing, which suggests to me that a
JsonObject.TryAdd
method similar to the one in #107947 might be necessary.
Originally posted by @eiriktsarpalis in dotnet/aspire#6312 (comment)
API Proposal
Exposing the APIs as approved for OrderedDictionary
to JsonObject
:
namespace System.Text.Json.Nodes;
public partial class JsonObject
{
public bool TryAdd(string propertyName, JsonNode? value, out int index);
public bool TryGetPropertyValue(string propertyName, out JsonNode? jsonNode, out int index);
}