Documentation Home
MySQL Shell 9.5
Download this Manual
PDF (US Ltr) - 2.5Mb
PDF (A4) - 2.5Mb


MySQL Shell 9.5  / ...  / MySQL Shell Utilities  / JSON Import Utility  /  Conversions for Representations of BSON Data Types

12.2.3 Conversions for Representations of BSON Data Types

When you specify theconvertBsonTypes: true (--convertBsonTypes) option to convert BSON data types that are represented by JSON extensions, by default, the BSON types are imported as follows:

Date (date)

Simple value containing the value of the field.

Timestamp (timestamp)

MySQL timestamp created using thetime_t value.

Decimal (decimal)

Simple value containing a string representation of the decimal value.

Integer (int orlong)

Integer value.

Regular expression (regex plus options)

String containing the regular expression only, and ignoring the options. A warning is printed if options are present.

Binary data (binData)

Base64 string.

ObjectID (objectId)

Simple value containing the value of the field.

The following control options can be specified to adjust the mapping and conversion of these BSON types.convertBsonTypes: true (--convertBsonTypes) must be specified to use any of these control options:

ignoreDate: true (--ignoreDate)

Disable conversion of the BSONdate type. The data is imported as an embedded JSON document exactly as in the input file.

ignoreTimestamp: true (--ignoreTimestamp)

Disable conversion of the BSONtimestamp type. The data is imported as an embedded JSON document exactly as in the input file.

decimalAsDouble: true (--decimalAsDouble)

Convert the value of the BSONdecimal type to the MySQLDOUBLE type, rather than a string.

ignoreRegex: true (--ignoreRegex)

Disable conversion of regular expressions (the BSONregex type). The data is imported as an embedded JSON document exactly as in the input file.

ignoreRegexOptions: false (--ignoreRegexOptions=false)

Include the options associated with a regular expression in the string, as well as the regular expression itself (in the format/<regular expression>/<options>). By default, the options are ignored (ignoreRegexOptions: true), but a warning is printed if any options were present.ignoreRegex must be set to the default offalse to specifyignoreRegexOptions.

ignoreBinary: true (--ignoreBinary)

Disable conversion of the BSONbinData type. The data is imported as an embedded JSON document exactly as in the input file.

The following example imports documents from the file/europe/regions.json to the columnjsondata in a relational table namedregions in themydb database. BSON data types that are represented by JSON extensions are converted to MySQL representations, with the exception of regular expressions, which are imported as embedded JSON documents:

mysqlsh user@localhost/mydb --import /europe/regions.json regions jsondata --convertBsonTypes --ignoreRegex