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
Copy file name to clipboardExpand all lines: _docs/pointer/basics.md
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,55 @@ var success = pointer.TryEvaluate(element, out var result);
87
87
> The designers of the `JsonNode` API have elected (for [reasons](https://github.com/dotnet/designs/blob/40794be63ecd8b35e9596412050a84dedd575b99/accepted/2020/serializer/WriteableDomAndDynamic.md#missing-vs-null) I [disagree](https://github.com/dotnet/runtime/issues/66948#issuecomment-1080148457) with) to consider JSON null and .Net null to be equivalent. This goes against both my personal experience building Manatee.Json and the `JsonElement` API, both of which maintain a separation between these two null concepts. Because of the unified design, it's impossible to determine whether a returned `JsonNode` value of `null` represents a value that is present but null or it is merely absent from the data. To accommodate this, the evaluation method can only support the familiar `TryParse()` signature. A return of `true` indicates the value was found, and `false` indicates it was not. In the case of a `true` return, `result` may still be null, indicating the value was found and was a JSON null.
88
88
{: .prompt-info }
89
89
90
+
### Pointer math
91
+
92
+
You can also combine and augment pointers in different ways.
93
+
94
+
Joining two pointers together:
95
+
96
+
```c#
97
+
varpointer1=JsonPointer.Parse("/objects/and");
98
+
varpointer2=JsonPointer.Parse("/3/arrays");
99
+
varfinal=pointer1.Combine(pointer2);
100
+
```
101
+
102
+
Appending additional segments to an existing pointer:
103
+
104
+
```c#
105
+
varpointer=JsonPointer.Parse("/objects/and");
106
+
varfinal=pointer1.Combine(3, "arrays");
107
+
```
108
+
109
+
### Access pointer parts and create sub-pointers
110
+
111
+
You can retrieve the individual segments using the indexer:
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
+
90
139
### Building pointers using Linq expressions {#linq}
91
140
92
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.
Copy file name to clipboardExpand all lines: _docs/schema/basics.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ There are two options when building a schema: defining it inline using the fluen
47
47
48
48
## Serialization and Deserialization {#schema-deserialization}
49
49
50
-
*JsonSchema.Net* schemas are fully serializable.
50
+
_JsonSchema.Net_ schemas are fully serializable.
51
51
52
52
```c#
53
53
varmySchema=JsonSchema.FromText(content);
@@ -463,7 +463,8 @@ New formats must be registered via the `Formats.Register()` static method. This
463
463
464
464
The `EvaluationOptions` class gives you a few configuration points for customizing how the evaluation process behaves. It is an instance class and can be passed into the `JsonSchema.Evaluate()` method. If no options are explicitly passed, a copy of `JsonSchemaOptions.Default` will be used.
465
465
466
-
-`EvaluateAs` - Indicates which schema version to process as. This will filter the keywords of a schema based on their support. This means that if any keyword is not supported by this version, it will be ignored.
466
+
-`EvaluateAs` - Indicates which schema version to process as. This will filter the keywords of a schema based on their support. This means that if any keyword is not supported by this version, it will be ignored. This will need to be set when you create the options.
467
+
-`SchemaRegistry` - Provides a way to register schemas only for the evaluations that use this set of options.
467
468
-`EvaluateMetaSchema` - Indicates whether the schema should be evaluated against its `$schema` value (its meta-schema). This is not typically necessary. Note that the evaluation process will still attempt to resolve the meta-schema. \*
468
469
-`OutputFormat` - You already read about output formats above. This is the property that controls it all. By default, a single "flag" node is returned. This also yields the fastest evaluation times as it enables certain optimizations.
Now *JsonSchema.Net* will be able to resolve the reference.
553
+
Now _JsonSchema.Net_ will be able to resolve the reference.
553
554
554
555
> `JsonSchema.FromFile()` automatically sets the schema's base URI to the file path. If you intend to use file paths in your references (e.g. `file:///C:\random-string.json`), then just register the schema without passing a URI:
555
556
>
@@ -576,7 +577,7 @@ var referenceableJson = new JsonNodeBaseDocument(json, "http://localhost/jsondat
0 commit comments