[5] 
[DFN[MongoDB Extended JSON]]
は
[[MongoDB]]
の[[データ形式]]の1つです。

[6] 
[[BSON]] のデータモデルに相当するものを、
[[JSON応用]]として、
または [[JSON]] っぽい独自ファイル形式で、
の2通りの方法で記述できます。
前者は [[JSON]] ですが、後者は [[JSONもどき]]です。

* 仕様書

[FIG(quote)[
[FIGCAPTION[
[1] [CITE@en[MongoDB Extended JSON — MongoDB Manual 2.6.7]]
([TIME[2015-01-24 08:03:15 +09:00]] 版)
<http://docs.mongodb.org/manual/reference/mongodb-extended-json/>
]FIGCAPTION]

> MongoDB Extended JSON
> JSON can only represent a subset of the types supported by BSON. To preserve type information, MongoDB adds the following extensions to the JSON format:
> Strict mode. Strict mode representations of BSON types conform to the JSON RFC. Any JSON parser can parse these strict mode representations as key/value pairs; however, only the MongoDB’s internal JSON parser also recognizes the type information conveyed by the format.
> mongo Shell mode. The MongoDB’s internal JSON parser and the mongo shell can parse this mode.

]FIG]

[4] [CITE@en[MongoDB Extended JSON (v1) — MongoDB Manual]], [TIME[2023-04-07T17:37:20.000Z]], [TIME[2023-04-16T11:38:06.931Z]] <https://www.mongodb.com/docs/manual/reference/mongodb-extended-json-v1/>

>JSON can only represent a subset of the types supported by BSON. To preserve type information, MongoDB adds the following extensions to the JSON format:[SNIP[]]

[3] [CITE@en[MongoDB Extended JSON (v2) — MongoDB Manual]], [TIME[2023-04-07T17:37:20.000Z]], [TIME[2023-04-16T11:40:28.413Z]] <https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/>

* データ型


[7] 
[[正規表現]]

** 日時

[9] v1 の
[DFN[[CODE[data_date]]]]
は
[[ISO 8601のプロファイル]] (パターン型の例示により規定) または[[ミリ秒Unix time]]。
[SRC[>>4]]

[11] 
v2 の [DFN[[CODE[Date]]]]
は
[[RFC 3339の日時形式]]のプロファイルまたは[[ミリ秒Unix time]]。
[SRC[>>3]]

[12] 
ここで、 [[RFC 3339]] 形式を使えるのは[[年]]が [ [N[1970]], [N[9999]] ] のとき。
[[秒の小数部]]は、
[N[0]] のとき省略する[SHOULD[べき]]。
そうでないときちょうど3桁。
[SRC[>>3]]


[10] v1 の
[DFN[[CODE[data_timestamp]]]],
v2
の
[DFN[[CODE[Timestamp]]]]
は[[Unix time]]。
[SRC[>>4, >>3]]

[8] [[BSONにおける日時]]も参照.

* 関連

[2] 関連: [[BSON]]

* メモ