5.0.2
Fixed a problem with .ToString()
where pointers constructed using JsonPointer.Create()
would not properly escape segments.
5.0.1
For some reason v5.0.0 was missing two methods: .GetAncestor()
and .GetLocal()
. This is a republish to include those methods.
5.0.0
Complete overhaul of JsonPointer
to reduce memory usage for consuming applications.
Benchmark showing performance of parsing various pointer strings before and after changes.
Version | Count | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|---|
4.0.1 | 1 | 5.830 us | 0.2559 us | 0.7300 us | 4.6387 | 9.48 KB |
5.0.0 | 1 | 3.188 us | 0.0492 us | 0.0460 us | 2.2583 | 4.62 KB |
4.0.1 | 10 | 54.627 us | 1.0469 us | 2.9355 us | 46.3867 | 94.77 KB |
5.0.0 | 10 | 31.482 us | 0.4489 us | 0.4199 us | 22.5830 | 46.17 KB |
4.0.1 | 100 | 537.704 us | 10.6843 us | 22.5369 us | 463.8672 | 947.66 KB |
5.0.0 | 100 | 329.112 us | 2.6580 us | 2.4863 us | 226.0742 | 461.72 KB |
Architecture change
JsonPointer
now holds the complete pointer string instead of individual segments. Segments are now exposed via an indexer and return ReadOnlySpan<char>
s which contain the JSON-Pointer-encoded segment. Use JsonPointer.SegmentEquals()
for zero-allocation string comparisons or the .GetSegmentName()
to decode to a string.
RelativeJsonPointer
as likewise been updated to a struct.
Breaking changes
JsonPointer
is now a struct.JsonPointer.Segments
removed.JsonPointer.Create(IEnumerable<PointerSegment>)
removed.PointerSegment
is now only an intermediary type for building pointers; non-constructable.RelativeJsonPointer
is now a struct.EnumerableExtensions.GetCollectionHashCode<T>()
removed.
Additions
JsonPointer
segment indexerJsonPointer.SegmentEquals(ReadOnlySpan<char>, string)
JsonPointer.GetAncestor(int)
(gets left part)JsonPointer.GetLocal(int)
(gets right part)NodeExtensions.TryGetSegment()
extension onJsonObject
to find a key using a JSON-Pointer-encoded char span.SpanExtensions
GetSegmentName()
decodes a pointer segment char span into a string nameGetSegmentIndex()
decoes a pointer segment char span into an integer indexTryGetInt()
attempts to parse an integer from a char span
4.0.1.x
#711 - Nuget package meta-data updates; no functional changes from previous version.
4.0.1
Fixed issue with equality operators on PointerSegment
when dealing with nulls.
4.0.0
Updated for multi-framework support with .Net Standard 2.0 and .Net 8 with Native AOT support, including updating System.Text.Json from v6 to v8.
Breaking changes
- Dropping support for .Net Standard 3.1 - May still be used, but exact behavior cannot be guaranteed.
CharExtensions
removed as it was not used.
Additions
JsonPointer.TypeInfoResolver
to expose all of the type resolvers contained in the library. Can be used to create a combined SerializationOptions
by using a Json.More.TypeResolverOptionsManager
in your JsonSerializerContext
.
3.3.0
#585 - Added support for TypeConverter
so that an application config can properly convert to JSON Pointer in config models. Thanks to @wazzamatazz for raising the issue and providing the implementation.
3.2.2
Implemented support for index modifiers for Relative JSON Pointers (e.g. the +1
in 0+1/foo
), which apparently just weren’t supported.
3.2.1
#555 - JSON Pointer creation using Linq expressions should support using local variables in indexers. Thanks to @OmiCron07 for suggesting.
3.2.0
#549 - Expose JSON converters for all types to support JSON source generation.
3.1.0
Enhanced support for creating pointers via Linq expressions.
- Added support for the Linq method
.Last()
to generate a-
segment which indicates the index beyond the last item in an array. - Added support for
[JsonPropertyName]
attribute. - Added support for custom naming transformations.
3.0.3
Improved performance for JsonPointer.ToString()
by caching the string representation so that it’s only generated once.
3.0.2
Memory and performance improvements.
3.0.1
#408 - Fixed an issue where an empty string segment fails for array values. Thanks to @mbj2011 for finding and reporting this.
3.0.0
Updated model to more correctly represent a basic JSON Pointer.
- URL encoding is merely a formatting concern
- Removed
UrlEmpty
Parse()
andTryParse()
are still tolerant of URL encoded pointers and will decode automatically- Removed
Source
property asToString()
is the default method for getting a string - Renamed
JsonPointerKind
toJsonPointerStyle
to reflect the formatting nature of its purpose - Added
ToString(JsonPointerKind)
to support outputting in URL encoded format
Added implicit cast from int
to PointerSegment
. Previously, only a cast from uint
existed, but typing int
s is easier.
2.2.1 (no PR)
#288 - Just bumping version to allow dependent packages to pick up the latest Json.More.Net by default, which is transitively pulled via this package.
2.2.0
Updated System.Text.Json to version 6 in order to add JsonNode
support.
The API is shaped a bit differently for JsonNode
than the existing API for JsonElement
. Specifically, it exposes
1
bool TryEvaluate(JsonNode node, out JsonNode? result)
instead of the Evaluate()
call you’ve all come to know and love.
This is because .Net decided to do a silly thing and represent JSON null using .Net null. This decision means that a null returned here cannot be distinguished between not existing and existing with a value of JSON null.
RelativeJsonPointer
is now implemented! …for JsonNode
.
2.1.0
#184 - @JanKnipp added array (e.g. int[]
) support to Linq expression construction of pointers.
2.0.0
#171 - Updated JsonPointer
, PointerSegment
, and RelativeJsonPointer
from struct to class since it holds by-reference data anyway. Removes parameterless constructor for these types. These changes make them better immutable models.
1.4.0
- Added implicit casts from
int
andstring
toPointerSegment
- Added params overload for
JsonPointer.Create()
.
1.3.3
#123 - Removed a copy/paste error that shows up while deserializing relative pointers. Thanks to @bastiaantenklooster for finding this and creating a PR to fix it.
1.3.2
Added support for nullable reference types.
1.3.1
Signed the DLL for strong name compatibility.
1.3.0
Added support pointer creation using lambda expressions, e.g. x => x.foo[5].bar
to create /foo/5/bar
.
1.2.0
Added support for array index manipulation in Relative JSON Pointer 2 (spec updated alongside JSON Schema Draft 2020-12).
1.1.2
Added debug symbols to package. No functional change.
1.1.1
Updated reference to Json.More
1.1.0
Added JsonPointerKind
enumeration.
Added JsonPointer.Kind
property.
Added optional parameters to JsonPointer.Parse()
and JsonPointer.TryParse()
.
1.0.0
Initial release.