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
There are also method versions of this functionality, which are also available if you're not yet using .Net 8: `.GetAncestor(int)` and `.GetLocal()`.
135
-
136
-
> Accessing pointers acts like accessing strings: getting segments has no allocations (like getting a `char` via the string's `int` indexer), but creating a sub-pointer _does_ allocate a new `JsonPointer` instance (like creating a substring via the string's `Range` indexer).
137
-
{: .prompt-info }
138
-
139
-
### Building pointers using Linq expressions {#linq}
140
-
141
-
When building a pointer using the `Create<T>()` method which takes a Linq expression, there are a couple of things to be aware of.
142
-
143
-
First, JSON Pointer supports using `-` as a segment to indicate the index beyond the last item in an array. This has several use cases including creating a JSON Patch to add items to arrays.
144
-
145
-
Secondly, you have some name transformation options at your disposal.
146
-
147
-
The first way to customize your pointer is by using the `[JsonPropertyName]` attribute to provide a custom name. Since this attribute controls how System.Text.Json serializes the property, this attribute will override any other options.
148
-
149
-
The second way to customize your pointer is by providing a `PointerCreationOptions` object as the second parameter. Currently there is only the single option: `PropertyNamingResolver`. This property is a function that takes a `MemberInfo` and returns the string to use in the pointer. Several presets have been created for you and are available in the `PropertyNamingResolvers` static class:
150
-
151
-
| Name | Summary |
152
-
|---|---|
153
-
|**AsDeclared**| Makes no changes. Properties are generated with the name of the property in code. |
154
-
|**CamelCase**| Property names to camel case (e.g. `camelCase`). |
155
-
|**KebabCase**| Property names to kebab case (e.g. `Kebab-Case`). |
156
-
|**PascalCase**| Property names to pascal case (e.g. `PascalCase`). |
157
-
|**SnakeCase**| Property names to snake case (e.g. `Snake_Case`). |
158
-
|**UpperKebabCase**| Property names to upper kebab case (e.g. `UPPER-KEBAB-CASE`). |
159
-
|**UpperSnakeCase**| Property names to upper snake case (e.g. `UPPER_SNAKE_CASE`). |
160
-
161
130
## Relative JSON Pointers {#pointer-relative}
162
131
163
132
[JSON Hyperschema](https://datatracker.ietf.org/doc/draft-handrews-json-schema-hyperschema/) relies on a variation of JSON Pointers called [Relative JSON Pointers](https://tools.ietf.org/id/draft-handrews-relative-json-pointer-00.html) that also includes the number of parent and/or array-index navigations. This allows the system to start at an internal node in the JSON document and navigate to another node potentially on another subtree.
0 commit comments