Reference

Numeric types

There are two numeric types in JSON Schema: integer and number. They share the same validation keywords.

JSON has no standard way to represent complex numbers, so there is no way to test for them in JSON Schema.

integer

The integer type is used for integral numbers. JSON does not have distinct types for integers and floating-point values. Therefore, the presence or absence of a decimal point is not enough to distinguish between integers and non-integers. For example, 1 and 1.0 are two ways to represent the same value in JSON. JSON Schema considers that value an integer no matter which representation was used.

Language-specific info:
Python
Ruby
Objective-C
Swift
In Python, "integer" is analogous to the int type.
schema
{ "type": "integer" }
data
42
compliant to schema
data
-1
compliant to schema

Numbers with a zero fractional part are considered integers:

data
1.0
compliant to schema

Floating point numbers are rejected:

data
3.1415926
not compliant to schema

Numbers as strings are rejected:

data
"42"
not compliant to schema

number

The number type is used for any numeric type, either integers or floating point numbers.

Language-specific info:
Python
Ruby
Objective-C
Swift
In Python, "number" is analogous to the float type.

Need Help?

Did you find these docs helpful?

Help us make our docs great!

At JSON Schema, we value docs contributions as much as every other type of contribution!

Still Need Help?

Learning JSON Schema is often confusing, but don't worry, we are here to help!.