Skip to main content

Dataset Schema ๐Ÿงช

MMDB CLI uses JSON dataset files for generate, update, and dump workflows.

Top-level Structureโ€‹

The dataset JSON supports these top-level fields:

FieldTypeDescriptionRequired
versionstringDataset format version. Current supported value: v1.No
schemaobjectOptional dynamic schema object used by generate/update.No
metadataobjectMMDB metadata used by generate (and included in dump output).generate: Yes
datasetarrayRecords or update operations (depends on command usage).Yes
{
"version": "v1",
"schema": {},
"metadata": {},
"dataset": []
}

version Fieldโ€‹

If version is provided, it must be v1.

metadata Field (for generate)โ€‹

The metadata object defines MMDB writer options when generating a database.

FieldTypeDescriptionRequired
DatabaseTypestringDatabase type (for example GeoLite2-ASN).Yes
DescriptionobjectLocalized description map (for example {"en":"..."}).Yes
IPVersionintegerAllowed values: 4, 6. Defaults to 6 if omitted.No
LanguagesarrayLanguage list. Defaults to ["en"] if omitted.No
RecordSizeintegerAllowed values: 24, 28, 32. Defaults to 28.No

dataset for generate / dumpโ€‹

For generate, each item in dataset must contain:

FieldTypeDescriptionRequired
networkstringNetwork address in CIDR notation (IPv4 or IPv6).Yes
recordobjectThe record data associated with the networkYes

Example:

{
"network": "1.1.1.0/24",
"record": {
"autonomous_system_number": 13335,
"autonomous_system_organization": "CLOUDFLARENET"
}
}

Supported Record Value Typesโ€‹

Record values are converted to MMDB types by MMDB CLI before writing.

Default type inference (no schema provided)โ€‹

When you do not provide a schema, MMDB CLI infers types from JSON values:

JSON valueStored MMDB type
stringstring
booleanbool
numberfloat64
objectmap/object (recursively converted)

Notes:

  • JSON numbers are typically parsed as floating-point values in this mode.
  • Nested objects are supported recursively.
  • Arrays and null are not supported by the current default converter.

Schema-driven typing (schema provided)โ€‹

If you provide a top-level schema object, you can force specific types per field.

Supported schema type keywords:

  • string
  • bool / boolean
  • float / float64
  • int / int32
  • uint / uint32
  • uint16

Schema can be nested for nested record objects:

{
"schema": {
"autonomous_system_number": "uint32",
"autonomous_system_organization": "string",
"is_cloudflare": "bool",
"attributes": {
"score": "float64"
}
}
}

If a value does not match the declared schema type, MMDB CLI falls back to a default value for that type (for example 0, false, or empty string).

End-to-end Examplesโ€‹

Example 1 - default inference (no schema):

{
"version": "v1",
"metadata": {
"DatabaseType": "GeoLite2-ASN-Custom",
"Description": {
"en": "Custom ASN Dataset"
},
"IPVersion": 6,
"RecordSize": 24
},
"dataset": [
{
"network": "1.1.1.0/24",
"record": {
"autonomous_system_number": 13335,
"autonomous_system_organization": "CLOUDFLARENET",
"is_anycast": true,
"confidence": 99.5,
"attributes": {
"region": "global"
}
}
}
]
}

Example 2 - schema-driven typing:

{
"version": "v1",
"schema": {
"autonomous_system_number": "uint32",
"autonomous_system_organization": "string",
"is_anycast": "bool",
"confidence": "float64",
"port": "uint16",
"attributes": {
"priority": "int32"
}
},
"metadata": {
"DatabaseType": "GeoLite2-ASN-Custom",
"Description": {
"en": "Typed ASN Dataset"
},
"IPVersion": 6,
"RecordSize": 24
},
"dataset": [
{
"network": "1.1.1.0/24",
"record": {
"autonomous_system_number": 13335,
"autonomous_system_organization": "CLOUDFLARENET",
"is_anycast": true,
"confidence": 99.5,
"port": 443,
"attributes": {
"priority": -1
}
}
}
]
}

dataset for updateโ€‹

For update, each item in dataset must contain:

FieldTypeDescriptionRequired
networkstringTarget CIDR to updateYes
methodstringOne of remove, replace, top_level_merge, deep_mergeNo (defaults to deep_merge)
dataobjectPayload used by update methodYes

Example:

{
"network": "1.1.1.1/32",
"method": "deep_merge",
"data": {
"is_cloudflare": true
}
}