You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it is not possible to enumerate property names from JsonElement as raw spans.
There are api's that let you get property once you know the name such as JsonElement.TryGetProperty(ReadOnlySpan<byte>, out JsonElement), but the result of object enumeration - JsonProperty has only one string property Name.
Using JsonProperty.Name converts utf8 data and allocates in getter. It should be possible to get property name as a raw ReadOnlySpan<byte>.
The text was updated successfully, but these errors were encountered:
It is also not possible to get raw string value as ReadOnlySpan<byte> from JsonElement that is a string. GetRawText() doesn't help - it returns string.
@ahsonkhan / @steveharter / @bartonjs if they know of a way to do this using current API. If using the reader I imagine you could get at ValueSequence/ValueSpan when reading a JsonTokenType.PropertyName. I don't see a great way get at the raw property Spans when using JsonElement.
JsonElement is intentionally hiding the encoding in this release so we don't box ourselves out of supporting a UTF-16 (string) based reader in the future.
If you're wanting an equality check, we have that with JsonProperty.NameEquals (or a value check is JsonElement.ValueEquals). Anything more than that requires transcoding to System.String.
Currently it is not possible to enumerate property names from
JsonElement
as raw spans.There are api's that let you get property once you know the name such as
JsonElement.TryGetProperty(ReadOnlySpan<byte>, out JsonElement)
, but the result of object enumeration -JsonProperty
has only onestring
propertyName
.Using
JsonProperty.Name
converts utf8 data and allocates in getter. It should be possible to get property name as a rawReadOnlySpan<byte>
.The text was updated successfully, but these errors were encountered: