Skip to content

Commit b877a46

Browse files
chores
1 parent 02a60ee commit b877a46

File tree

1 file changed

+13
-9
lines changed
  • pages/understanding-json-schema/reference

1 file changed

+13
-9
lines changed

pages/understanding-json-schema/reference/type.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ At its core, JSON Schema defines the following basic types:
1515

1616
- [array](../../understanding-json-schema/reference/array)
1717
- [boolean](../../understanding-json-schema/reference/boolean)
18+
- [integer](../../understanding-json-schema/reference/numeric)
1819
- [null](../../understanding-json-schema/reference/null)
19-
- [numeric types](../../understanding-json-schema/reference/numeric)
20+
- [number](../../understanding-json-schema/reference/numeric)
2021
- [object](../../understanding-json-schema/reference/object)
21-
- [regular expressions](../../understanding-json-schema/reference/regular_expressions)
2222
- [string](../../understanding-json-schema/reference/string)
2323

2424

@@ -35,7 +35,8 @@ analogous types in Python:
3535
| JSON | Python |
3636
|---------|--------------|
3737
| string | string [1] |
38-
| number | int/float [2]|
38+
| number | int/float |
39+
| integer | int |
3940
| object | dict |
4041
| array | list |
4142
| boolean | bool |
@@ -47,8 +48,7 @@ analogous types in Python:
4748
analogous to `unicode` on Python 2.x and `str` on
4849
Python 3.x.
4950

50-
[2] JSON does not have separate types for integer and
51-
floating-point.
51+
[2] JSON defines a single numeric literal, but JSON Schema distinguishes between `number` (any numeric value) and `integer` (no fractional part).
5252

5353
[tab "Ruby"]
5454

@@ -59,15 +59,15 @@ analogous types in Ruby:
5959
|---------|----------------------|
6060
| string | String |
6161
| number | Integer/Float [3] |
62+
| integer | Integer |
6263
| object | Hash |
6364
| array | Array |
6465
| boolean | TrueClass/FalseClass |
6566
| null | NilClass |
6667

6768
#### Footnotes
6869

69-
[3] JSON does not have separate types for integer and
70-
floating-point.
70+
[3] JSON defines a single numeric literal, but JSON Schema distinguishes `number` and `integer`.
7171

7272
[tab "Perl"]
7373

@@ -78,6 +78,7 @@ their analogous types in Perl:
7878
|---------|--------------------------------------------------|
7979
| string | scalar (SV) |
8080
| number | scalar (NV or IV), or Math::BigNum, Math::BigInt |
81+
| integer | scalar (IV) |
8182
| object | reftype=HASH |
8283
| array | reftype=ARRAY |
8384
| boolean | scalar or JSON::PP::Boolean |
@@ -92,6 +93,7 @@ their analogous types in Objective-C:
9293
|---------|--------------|
9394
| string | NSString |
9495
| number | NSNumber |
96+
| integer | NSNumber |
9597
| object | NSDictionary |
9698
| array | NSArray |
9799
| boolean | NSNumber [4]|
@@ -112,6 +114,7 @@ their analogous types in Swift:
112114
|---------|------------|
113115
| string | String |
114116
| number | Int/Double [5]|
117+
| integer | Int |
115118
| object | Dictionary |
116119
| array | Array |
117120
| boolean | Bool |
@@ -127,7 +130,7 @@ to decode ``Int`` from a non-integer number in JSON.
127130

128131
The `type` keyword can take two forms:
129132

130-
1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type.
133+
1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object` or `string`). This specifies that the instance data is only valid when it matches that specific type.
131134

132135
Here is an example of using `"number"` as a single string value:
133136

@@ -178,6 +181,7 @@ JSON Schema offers a variety of keywords to validate data against specific types
178181
| [array](../../understanding-json-schema/reference/array) | `items`, `additionalItems`, `minItems`, `maxItems`, `uniqueItems` | Define item schemas, additional item handling, item count constraints, and uniqueness. |
179182
| [number](../../understanding-json-schema/reference/numeric) | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf` | Define numeric ranges, including exclusive bounds and divisibility. |
180183
| [object](../../understanding-json-schema/reference/object) | `required`, `properties`, `additionalProperties`, `patternProperties`, `minProperties`, `maxProperties`, `dependencies` | Define required properties, property schemas, additional property handling, pattern-based property matching, and property count constraints. |
184+
| [integer](../../understanding-json-schema/reference/numeric) | Same as `number` | Integers use numeric constraints but must not contain a fractional part. |
181185
| [string](../../understanding-json-schema/reference/string) | `minLength`, `maxLength`, `pattern`, `format`| Restrict string length, pattern matching, and format validation (e.g., email, date). |
182186

183187

@@ -206,7 +210,7 @@ The JSON Schema specification has a bias toward networking-related formats due t
206210

207211
### Built-in Formats
208212

209-
It should be noted that `format` is not limited to a specific set of valid values or types. Users may define their own custom keywords including ones that work with JSON data types other than `string`, such as `number`. Below, we cover the formats specified in the JSON Schema specification.
213+
It should be noted that `format` is not limited to a specific set of valid values or types. Users may define custom formats through vocabularies, but the built-in formats apply only to strings.
210214

211215
#### Dates and Times
212216

0 commit comments

Comments
 (0)