# Using Document View for JSON columns

{% hint style="info" %}
Only supported for the file connector and PostgreSQL.

Note that for PostgreSQL, **Document View** cannot be used when the entire JSON document is an array. The JSON can contain arrays, but the document itself cannot be an array.
{% endhint %}

For columns that contain JSON content, you can use the JSON Mask generator to assign generators to individual JSON fields. To identify the fields, you use JSONPath expressions.

Another option is to use **Document View**, which allows you to view the structure of the JSON content and then assign generators to individual JSON fields.

You can also view this [video overview of **Document View**](https://www.youtube.com/watch?v=XCMezJ-Kst4).

## Enabling Document View for a JSON column <a href="#column-enable-document-view" id="column-enable-document-view"></a>

For a JSON column, the **Document View** option is available from **Privacy Hub**, **Database View**, and **Table View**.

On the column configuration panel, to enable **Document View**, toggle **Use Document View** to the on position. When you enable document parsing:

* The generator dropdown changes to an **Open in Document View** button.
* If this is the first column that you enabled **Document View** for, then the **Document View** tab becomes visible.
* Any existing generator assignment is discarded.
* On **Privacy Hub**, in the protection status display, each JSON path is displayed as a separate column. In the **Database Tables** list, each JSON path is a separate entry.

Structural also runs a scan on the column to detect the JSON structure and identify sensitive fields.

## Displaying Document View <a href="#document-view-display" id="document-view-display"></a>

On workspace management view, you use **Document View** to view the JSON structure.

**Document View** is only available when it is enabled for at least one JSON column.

## Selecting the JSON column to configure <a href="#document-view-select-column" id="document-view-select-column"></a>

From the **Column** dropdown list, select the JSON column to configure. The dropdown contains the columns that have **Document View** enabled.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FWNh9KPQZHHByECWOFIbP%2FDocumentViewColumnDropdown.png?alt=media&#x26;token=178778e0-e2aa-44c6-8663-ac57c13fb3d7" alt=""><figcaption><p>Column dropdown list on Document View</p></figcaption></figure>

## Selecting the type of view <a href="#document-view-select-view" id="document-view-select-view"></a>

From the **View** dropdown list, select the view to use for the selected column.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FLHfTAd2F97YO6SWowKjx%2FDocumentViewViewDropdown.png?alt=media&#x26;token=589c2821-be9b-4fd7-96d0-dafd0fb53462" alt=""><figcaption><p>View dropdown on Document View</p></figcaption></figure>

### Hybrid view

Hybrid view provides a consolidated view of the schema across all of the rows.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FibmwEvSgUgFsQo6fhH0G%2FDocumentViewHybrid.png?alt=media&#x26;token=226c6711-08a7-4f8b-8c07-757fa512c7af" alt=""><figcaption><p>Hybrid view of Document view</p></figcaption></figure>

For example, for an array, hybrid view contains a single entry with all of the possible fields.&#x20;

### Single view

Single view shows the structure for one row at a time. You can then page through up to 100 rows. For each row, Structural displays the row structure.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FGeEvTxZnP7llVNivW1zE%2FDocumentViewSingle.png?alt=media&#x26;token=6f5034ac-c56a-4cdd-a359-d7a2f1a35804" alt=""><figcaption><p>Single view of Document view</p></figcaption></figure>

For example, for an array, single view shows the actual array entries for each record.

## Information in the field list <a href="#document-view-field-list-info" id="document-view-field-list-info"></a>

For each JSON field, **Document View** always displays:

* The field name and data type.
* The assigned generator.
* An example value. In hybrid view, you can use the magnifying glass icon to display additional example values.

Hybrid view also displays a **Field Freq** column. **Field Freq** shows the percentage of rows that contain that permutation of field and type. For example, a field might be Null 33% of the time and contain a numeric value 67% of the time. Or a field value might be an Int32 value 3% of the time and an Int64 value 6% of the time. The percentages apply to the first 100 rows.

## Toggling between source and preview data <a href="#document-view-source-preview-toggle" id="document-view-source-preview-toggle"></a>

{% hint style="info" %}

**Required workspace permission:**

* **Source data:** Preview source data
* **Destination data:** Preview destination data
  {% endhint %}

The **Preview** toggle at the top right of **Document View** allows you to choose whether to display original source data or the transformed data. You can switch back and forth to determine exactly how Tonic Structural transforms the data based on the field configuration.

By default, the **Preview** toggle is in the on position, and the displayed data reflects the assigned generators.

To display the original source data, toggle **Preview** to the off position.

## Filtering Document View fields <a href="#document-view-filter-fields" id="document-view-filter-fields"></a>

In single view, you can filter by either a field name or a field value.

In hybrid view, you can filter by either field name or field properties.

### **Filtering single document view by field name or value** <a href="#filter-single-name-value" id="filter-single-name-value"></a>

You can filter single view to only display fields that have specific text in either the field name or the field value.

To filter by value, toggle **Search by Value** to the on position.

After you select the filter type, in the search field, type text that is in the field name or value. As you type, Structural filters the list to only include fields that contain the filter text.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2Fo5Lmec9MYKG7dpQhzM89%2FDocumentViewSearchByValue.png?alt=media&#x26;token=ebe87bce-6d8d-42b1-8cb7-2b2e549fd25b" alt=""><figcaption><p>Searching single view by field value</p></figcaption></figure>

### **Filtering hybrid view by field name** <a href="#filter-hybrid-name" id="filter-hybrid-name"></a>

To filter hybrid view by field name, in the search field, begin typing text that is in the field name. As you type, Structural filters the list to only include fields with names that include the filter text.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2Fhasg6EE7BKO5kaGHxVIr%2FDocumentViewSearchByName.png?alt=media&#x26;token=0934385f-4642-40ef-b759-aac3fa267b8f" alt=""><figcaption><p>Searching hybrid view by field name</p></figcaption></figure>

### **Filtering hybrid view by field properties** <a href="#filter-hybrid-field-properties" id="filter-hybrid-field-properties"></a>

From the hybrid document view, you can filter the fields based on field properties.

To display the **Filters** panel, click **Filters**.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FujoBGO1OH8n4FPSM29Qz%2FDocumentViewFiltersPanel.png?alt=media&#x26;token=d025ad9d-70ef-44b2-ac6c-bdab1e3063ab" alt=""><figcaption><p>Filters panel on Document View</p></figcaption></figure>

#### **Searching for a filter** <a href="#filter-properties-search" id="filter-properties-search"></a>

To search for a filter or a filter value, in the search field, start to type the value. The search looks for text in the individual settings.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FQRlKKlme2wO5IRzzCdX4%2FDocumentViewFilterSearch.png?alt=media&#x26;token=de8e7687-aae8-4d5c-aa44-0d96682be8bb" alt=""><figcaption><p>Filter search for Document View</p></figcaption></figure>

#### **Adding a filter** <a href="#filter-properties-add" id="filter-properties-add"></a>

To add a filter, depending on the filter type, either check the checkbox or select a filter option. As you add filters, Structural applies them to the field list.

Above the list, Structural displays tags for the selected filters.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2F9dqLIQUfeJsglJ3oFUoD%2FDocumentViewFiltersApplied.png?alt=media&#x26;token=1710bdc7-3904-4c86-b7bc-2ce2cff01568" alt=""><figcaption><p>Document View with applied filters</p></figcaption></figure>

#### **Clearing the selected filters** <a href="#filter-properties-clear" id="filter-properties-clear"></a>

To clear all of the currently selected filters, click **Clear All**.

## Filters panel filters

The **Filters** panel in hybrid view includes the following options.

### **At-risk JSON fields**

An at-risk JSON field:

* Is marked as sensitive
* Is assigned the Passthrough generator.

To only display at-risk JSON fields, on the **Filters** panel, check **At-Risk Field**.

When you check **At-Risk Field**, Structural adds the following filters under **Privacy Settings**:

* Sets the sensitivity filter to **Sensitive**.
* Sets the protection status filter to **Not protected**.

### **Sensitivity**

You can filter the JSON fields based on the field sensitivity.

On the **Filters** panel, under **Privacy Settings**, the sensitivity filter is by default set to **All**, which indicates to display both sensitive and non-sensitive JSON fields.

* To only display sensitive JSON fields, click **Sensitive**.
* To only display non-sensitive JSON fields, click **Not sensitive**.

Note that when you check **At-risk Field**, Structural automatically selects **Sensitive**.

### **Protection status**

You can filter the JSON fields based on whether they have any generator other than Passthrough assigned.

On the **Filters** panel, under **Privacy Settings**, the field protection filter is by default set to **All**, which indicates to display both protected and not protected JSON fields.

* To only display JSON fields that have an assigned generator, click **Protected**.
* To only display JSON fields that do not have an assigned generator, click **Not protected**.

Note that when you check **At-Risk Field**, Structural automatically selects **Not protected**.

### **Recommended generators**

When Structural detects that a JSON field is sensitive, it can also determine a recommended generator.

For example, when it detects a name value, it also recommends the Name generator.

You can filter the fields to display the fields that have recommended generators.

On the **Filters** panel, under **Recommended Generators**, check the checkbox next to the recommended generator for which to display the fields that have that recommendation.

### **Field data type**

You can filter the fields by the field data type. For example, you might only display columns that contain either numeric or integer values.

To only display fields that have specific data types, on the **Filters** panel, under **Database Data Types**, check the checkbox for each data type to include.

The list of data types only includes data types that are present in the currently displayed fields and that are compatible with other applied filters.

To search for a specific data type, in the **Filters** search field, begin to type the data type.

### **Unresolved schema changes**

When the structure of the JSON changes, you might need to update the configuration to reflect those changes. If you do not resolve the changes, then the data generation might fail.

To only display fields that have unresolved changes to the JSON structure, on the **Filters** panel, check **Unresolved Schema Changes**.

### **Sensitivity type**

For detected sensitive fields, the sensitivity type indicates the type of data that was detected. Examples of sensitivity types include First Name, Address, and Email.

To only display fields that contain specific sensitivity types, on the **Filters** panel, under **Sensitivity Type**, check the checkbox for each sensitivity type to include.

The list of sensitivity types only includes sensitivity types that are present in the currently displayed fields.

To search for a specific sensitivity type, in the **Filters** search field, type the sensitivity type.

### **Sensitivity confidence**

When the document scan identifies a value as belonging to a sensitivity type, it also determines how confident it is in that determination.

You can filter the columns based on the confidence level.

To only display columns that have a specific confidence level, on the **Filters** panel, under **Sensitivity confidence**, check the checkbox next to each confidence level to include.

## Indicating whether a JSON field is sensitive <a href="#json-field-sensitivity" id="json-field-sensitivity"></a>

{% hint style="info" %}
**Required workspace permission:** Configure column sensitivity
{% endhint %}

On the field configuration panel, the sensitivity toggle at the top right indicates whether the field is marked as sensitive.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2Fa84ikQyjuZJhG8sMlmEU%2FDocumentViewFieldConfig.png?alt=media&#x26;token=b08d7213-bf80-4dac-b324-2c0513cb8470" alt=""><figcaption><p>Field configuration panel on Document View</p></figcaption></figure>

To mark a field as sensitive, toggle the setting to the **Sensitive** position.

To mark a field as not sensitive, toggle the setting to the **Not Sensitive** position.

## Assigning a generator to a JSON field <a href="#json-field-generator" id="json-field-generator"></a>

{% hint style="info" %}
**Required workspace permission:** Configure column generators
{% endhint %}

For each node, you assign a generator.

To assign a generator:

1. Click the generator value for the JSON field.
2. On the configuration panel, from the **Generator Type** dropdown list, select the generator.\
   \
   Other than the Conditional and Regex Mask generators, you cannot assign a composite generator to a JSON field.
3. Configure the generator options. For details about the available configuration options for each generator, go to the [generator reference](https://docs.tonic.ai/app/generation/generators/generator-reference).

When you configure a generator in **Document View**:

* You can only link to other JSON fields.
* You can only enable self-consistency.

## Assigning generators to fields that match JSONPath expressions <a href="#document-view-path-expression" id="document-view-path-expression"></a>

In addition to assigning generators to individual fields, you can assign generators to generic paths. The paths use JSONPath syntax.

For more information, go to [document-path-expressions](https://docs.tonic.ai/app/generation/working-with-document-based-data/document-path-expressions "mention").
