Skip to content

Commit 6ad41cd

Browse files
authored
Merge pull request #25 from json-everything/schema/v8
updated docs
2 parents 45b159f + 115f549 commit 6ad41cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+403
-805
lines changed

.jekyll-metadata

-7.08 KB
Binary file not shown.

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ end
1010

1111
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
1212
# and associated library.
13-
platforms :mingw, :x64_mingw, :mswin, :jruby do
13+
platforms :windows, :jruby do
1414
gem "tzinfo", ">= 1", "< 3"
1515
gem "tzinfo-data"
1616
end
1717

1818
# Performance-booster for watching directories on Windows
19-
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
19+
# gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
2020

2121
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
2222
# do not have a Java counterpart.

_docs/pointer/basics.md

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,8 @@ There are three ways create pointers:
6262
```c#
6363
var pointer = JsonPointer.Create("object", "and", 3, "arrays");
6464
```
65-
- building with `Create<T>()` and supplying a LINQ expression (also see [below](#linq))
66-
```c#
67-
var pointer = JsonPointer.Create<MyObject>(x => x.objects.and[3].arrays);
68-
```
6965

70-
All of these options will give you an instance of the model that can be used to evaluate JSON data.
66+
Both of these options will give you an instance of the model that can be used to evaluate JSON data.
7167

7268
```c#
7369
using var element = JsonDocument.Parse("{\"objects\":{\"and\":[\"item zero\",null,2,{\"arrays\":\"found me\"}]}}");
@@ -121,43 +117,16 @@ Get the immediate parent:
121117

122118
```c#
123119
var pointer = JsonPointer.Parse("/objects/and/3/arrays");
124-
var parent = pointer[..^1]; // /objects/and/3
120+
var parent = pointer.GetParent(); // /objects/and/3
125121
```
126122

127123
Or get the local pointer (imagine you've navigated to `/objects/and/` and you need the pointer relative to where you are):
128124

129125
```c#
130126
var pointer = JsonPointer.Parse("/objects/and/3/arrays");
131-
var local = pointer[^2..]; // /3/arrays
127+
var local = pointer.GetLocal(2); // /3/arrays
132128
```
133129

134-
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-
161130
## Relative JSON Pointers {#pointer-relative}
162131

163132
[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.

_docs/schema/basics.md

Lines changed: 89 additions & 167 deletions
Large diffs are not rendered by default.

_docs/schema/close.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
title: __close
33
permalink: /schema/:title/
44
close: true
5-
order: "01.9"
5+
order: "01.10"
66
---

_docs/schema/codegen/close.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
title: __close
33
close: true
44
permalink: /schema/codegen/:title/
5-
order: "01.6.9"
5+
order: "01.07.9"
66
---

_docs/schema/codegen/mini-meta-schemas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: page
33
title: Mini-Meta-Schema Reference
44
permalink: /schema/codegen/:title/
55
icon: fas fa-tag
6-
order: "01.6.3"
6+
order: "01.07.3"
77
---
88
> **DEPRECATION NOTICE**
99
>

_docs/schema/codegen/patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: page
33
title: Supported Patterns
44
permalink: /schema/codegen/:title/
55
icon: fas fa-tag
6-
order: "01.6.2"
6+
order: "01.07.2"
77
---
88
> **DEPRECATION NOTICE**
99
>

_docs/schema/codegen/schema-codegen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Generating Code from JSON Schema
44
bookmark: Basics
55
permalink: /schema/codegen/:title/
66
icon: fas fa-tag
7-
order: "01.6.1"
7+
order: "01.07.1"
88
---
99
> **DEPRECATION NOTICE**
1010
>

_docs/schema/codegen/title.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ title: __title
33
bookmark: Code Generation
44
permalink: /schema/codegen/:title/
55
folder: true
6-
order: "01.6"
6+
order: "01.07"
77
---

0 commit comments

Comments
 (0)