JSON Support

From ER/Studio Data Architect
Jump to: navigation, search

Go Up to Supported Database Platforms

The Javascript Object Notation is a file-based format containing a hierarchical structure of fields. Fields that contain substructures can be thought of as Nested Objects which in turn have fields and substructures. ER/Studio allows you to model these hierarchical structures and convert them to and from relational logical data models. A common use case is to create a logical data model representing a canonical or polyglot model for multiple JSON message structures held as physical data models. We do this in the same way we do for database platforms.

Data Architect will reverse engineer JSON instance data or JSON Schema files to produce a physical data model. For the hierarchical structures in these JSON documents, Data Architect will render these as rolled-up structures inside the Collections for ease of viewing. It will also generate a logical data model based on the objects it finds within the JSON.


Generating a Physical Data Model for JSON

The Generate Database wizard differs for each target platform but for JSON models there will be the following options: For JSON Instance on Page 2 of the wizard

Propagated Foreign Key properties can be removed from generated objects or made as native fields which may be useful later to connect objects together elsewhere via code.

The Rolled Up View

The object view is useful to understand the reuse of objects and edit the cardinality to Nested Objects. You can also select a rendering of the model that is easier to visualize the hierarchical nature of the model.

  1. On the Diagram tab of the ribbon bar select Diagram/Display Options DiagramObject Display.png
  2. On the Object tab select the checkbox 'Roll Up Contained Objects'


Json physical model.png

Forward Engineering

For guidance on how to forward engineering JSON, please see Generating a Script File or Database. The Generate Database wizard will produce sample JSON output or JSON Schema files. For JSON Schema files you can opt to output Draft 07 or Draft 2020-12. For Draft 202-12 there are options to control whether Nested Objects are set as reused and added to the $defs section of the JSON Schema file or embedded locally in their parent objects. There are also options for addressing reusable definitions.

Import File

For a walkthrough of how to import a JSON instance or schema file, please see Importing a Model from a JSON File.


Nested Objects

Where objects are nested within objects, the wizard creates separate objects that are created with a containment relationship. For example the following JSON object has nested objects within the "name" object:

"name": {
"first": "John",
"last": "Smith"
},

Magic Wand Icon.pngTip: Separate object creation is useful for improved modeling. For example, nested objects such as address can be shared between different objects rather than duplicated. This also allows modifications to be made to all address fields without having to change each nested item individually.

JSON Schema Properties

The Table Editor allows you to view and edit the properties of an object and its fields. Many of these properties won't apply to JSON instance files but will be used in JSON Schema generation.

Features such as enumerated lists can be created by using Reference Values and binding them to fields in the Reference Values tab. For more information see Defining Valid Attribute Data Using Reference Values

See Also