This workaround requires dual lookup if the key is missing, which suggests to me that a JsonObject.TryAddmethod similar to the one in #107947 might be necessary.
Originally posted by @eiriktsarpalis in microsoft/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);
}
Originally posted by @eiriktsarpalis in microsoft/aspire#6312 (comment)
API Proposal
Exposing the APIs as approved for
OrderedDictionarytoJsonObject: