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: doc/schema.md
+274-6Lines changed: 274 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ RapidJSON implemented a JSON Schema validator for [JSON Schema Draft v4](http://
8
8
9
9
[TOC]
10
10
11
-
# Basic Usage {#BasicUsage}
11
+
# Basic Usage {#Basic}
12
12
13
13
First of all, you need to parse a JSON Schema into `Document`, and then compile the `Document` into a `SchemaDocument`.
14
14
@@ -52,11 +52,11 @@ Some notes:
52
52
* One `SchemaDocument` can be referenced by multiple `SchemaValidator`s. It will not be modified by `SchemaValidator`s.
53
53
* A `SchemaValidator` may be reused to validate multiple documents. To run it for other documents, call `validator.Reset()` first.
54
54
55
-
# Validation during parsing/serialization {#ParsingSerialization}
55
+
# Validation during parsing/serialization {#Fused}
56
56
57
57
Unlike most JSON Schema validator implementations, RapidJSON provides a SAX-based schema validator. Therefore, you can parse a JSON from a stream while validating it on the fly. If the validator encounters a JSON value that invalidates the supplied schema, the parsing will be terminated immediately. This design is especially useful for parsing large JSON files.
58
58
59
-
## DOM parsing {#DomParsing}
59
+
## DOM parsing {#DOM}
60
60
61
61
For using DOM in parsing, `Document` needs some preparation and finalizing tasks, in addition to receiving SAX events, thus it needs some work to route the reader, validator and the document. `SchemaValidatingReader` is a helper class that doing such work.
62
62
@@ -97,7 +97,7 @@ if (!reader.GetParseResult()) {
97
97
}
98
98
~~~
99
99
100
-
## SAX parsing {#SaxParsing}
100
+
## SAX parsing {#SAX}
101
101
102
102
For using SAX in parsing, it is much simpler. If it only need to validate the JSON without further processing, it is simply:
103
103
@@ -144,7 +144,7 @@ if (!d.Accept(validator)) {
144
144
145
145
Of course, if your application only needs SAX-style serialization, it can simply send SAX events to `SchemaValidator` instead of `Writer`.
146
146
147
-
# Remote Schema {#RemoteSchema}
147
+
# Remote Schema {#Remote}
148
148
149
149
JSON Schema supports [`$ref` keyword](http://spacetelescope.github.io/understanding-json-schema/structuring.html), which is a [JSON pointer](doc/pointer.md) referencing to a local or remote schema. Local pointer is prefixed with `#`, while remote pointer is an relative or absolute URI. For example:
150
150
@@ -176,7 +176,7 @@ The failed test is "changed scope ref invalid" of "change resolution scope" in `
176
176
177
177
Besides, the `format` schema keyword for string values is ignored, since it is not required by the specification.
178
178
179
-
## Regular Expression {#RegEx}
179
+
## Regular Expression {#Regex}
180
180
181
181
The schema keyword `pattern` and `patternProperties` uses regular expression to match the required pattern.
182
182
@@ -235,3 +235,271 @@ On a Mac Book Pro (2.8 GHz Intel Core i7), the following results are collected.
0 commit comments