Edit BSON Files in Grid View
Since BSON is a binary file format it cannot be viewed or edited in Text View. However you can create, edit, and save BSON files in Grid View. The display and behavior of BSON files in Grid View is similar to that of JSON files, but editing features enable you to also use the additional BSON datatypes. The various editing features of Grid View are described in this topic.
Standard file-related features
The BSON file format is included as a standard XMLSpy file format. So you can do the following:
•Create a new file extension and set it as BSON-conformant (Tools | Options | File Types). This enables XMLSpy to recognize files as being BSON.
•Currently, the .bson format has been set as BSON-conformant. You can set addition file extensions to be BSON-conformant.
•When creating a new empty file, you can generate a starting BSON outline file. If, during the creation procedure, you choose to assign a JSON schema to it, then the new BSON file will be created with the document structure defined in the JSON schema.
Note: The Examples project (see the Project window) contains BSON files for you to experiment with.
Display and edit files in Grid View
When you create a new BSON file or open an existing BSON file, it will be displayed in Grid View (screenshot below), which enables you to see the structure of the document at a glance. (You can scroll and expand/collapse items to view the document structure at different levels.)
Additionally, the structure can be easily modified by adding, deleting, or moving objects in the grid. Entire blocks of text can be reorganized (for example, by sorting them or moving them). Content, too, can be edited easily in Grid View, this being made even easier with the availability of in-cell commands in individual cells.
Furthermore, if a node is repeated (such as the objects in the servlet array shown in the screenshot above), then instead of each object repeating in serial order, they can be displayed in a table format, where the keys of key–value pairs in the objects are displayed as columns of the table and each object is displayed in a numbered row (see the table in the screenshot above).
Grid View provides you with other powerful features for displaying your JSON or BSON document in graphical form (such as a split view, filters, and charts), as well as editing features such as drag-and-drop and the ability to create formulas that generate new data.
For a full description of Grid View features, see the Editing Views | Grid View section.
BSON datatypes and editing
Note the following points about BSON datatypes in XMLSpy.
•JSON number is split into BSON int, long, double, and decimal.
•javascript and symbol (deprecated) behave like string.
•objectId and date each has a single value string representation.
•Single-value types (numbers, objectId, and date) are auto-detected.
•minKey, maxKey, and undefined (deprecated) have a fixed string representation.
•binData, regex, timestamp, and dbPointer (deprecated) have a pair of values. They show a JSON-like preview, and the values can be edited via dialogs (screenshot below).
•For easy readability, the summary and preview of collapsed nodes are displayed using a simple extended JSON format (see screenshot below). This format omits all type-preserving $-prefixed property names.
•Filters and formulas also work on the basis of simple extended JSON.
Entry helpers
The entry helpers Siblings, Children, and Values provide information about document structure in relation to the cursor position. This information is obtained from the associated JSON schema.
XQuery locator expressions
XQuery expressions for JSON are supported as follows:
•Place the cursor in the document and select Edit | Copy XPath (Ctrl+Shift+C) to copy to the clipboard an XQuery locator expression for that cursor location.
•In the XPath/XQuery Window, you can enter an XQuery expressions for JSON to evaluate it. You can go to a node displayed in the result by clicking it.