Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 858 Bytes

ExtendedJSON.md

File metadata and controls

21 lines (13 loc) · 858 Bytes

ExtendedJSON

MongoDB extended JSON is a type-safe representation of BSON as JSON String. This library contains a parser/serializer for that.

When receiving a JSON object that is MongoDB extended JSON you can initialize the Array/Dictionary Document using the intializer:

let document = Document(extendedJSON: jsonString)

Documents (and other ValueConvertibles) can also be serialized to a String using the makeExtendedJson() -> String functionality.

let jsonString = document.makeExtendedJSON()

Both are easily convertible to- and from each other.

Extended JSON is particularely useful in combination with a JavaScript client which is able to interact with MongoDB Extended JSON.

This allows you to - for example - transfer a date as a typed object which the Javascript client would convert back into a DateTime object.