# JSON Mask (JsonMaskGenerator)

The [JSON Mask](/app/generation/generators/generator-reference/json-mask.md) generator runs a selected generator on values that match a specified JSONPath.

## Link object structure <a href="#generator-api-json-mask-link-object" id="generator-api-json-mask-link-object"></a>

For the JSON Mask generator, you provide a link object for each sub-generator configuration.

The generator does not itself support consistency or differential privacy.

The `metadata` object is populated from the [`JsonMaskMetadata`](https://app.tonic.ai/apidocs/index.html#/models/JsonMaskMetadata) object, and includes:

* `pathExpression`, which is the JSONPath that identifies the value to apply the sub-generator to.
* The types of values to apply the sub-generator to.
* The `subGeneratorMetadata` object, which identifies and configures the sub-generator.

Here is the basic structure of a link object for a JSON Mask sub-generator.

{% code overflow="wrap" %}

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "metadata": {
    "generatorId": "JsonMaskGenerator",
    "customValueProcessor": "string",  //If custom value processor applied  
    "pathExpression": "string",
    "jsonFilterTypes": [ enum ], 
    "subGeneratorMetadata": {
      "generatorId": "string",
      "presetId": "string",
      //Metadata for the selected sub-generator
      "customValueProcessor": "string"  //If custom value processor applied to the sub-generator
    }
  }
}
```

{% endcode %}

## Example replacement <a href="#generator-api-json-mask-replacement" id="generator-api-json-mask-replacement"></a>

In the following example replacement for the JSON Mask generator:

* The Date Truncation generator is applied to all values of the JSONPath expression `$[*].start`. The value is truncated to the year, and the birthdate flag is off.
* The Email generator is applied to all values of the JSONPath expression `$[0].email`. The generated email addresses all use gmail.com as the domain, and no domains are excluded. Invalid email addresses are replaced. Consistency is disabled.
* If there is an error applying those generators, then the fallback generator is the Null generator.

```json
{
  "name": "json_data",
  "schema": "public"
  "table": "big_json",
  "links": [
    {
      "schema": "public",
      "table": "big_json",
      "column": "json_data",
      "metadata": {
        "generatorId": "JsonMaskGenerator",
        "presetId": "JsonMaskGenerator",
        "pathExpression": "$[*].start",
        "jsonFilterTypes": [
          0
        ],
        "subGeneratorMetadata": {
          "presetId": "DateTruncationGenerator",
          "generatorId": "DateTruncationGenerator",
          "datePart": "Year",
          "isBirthDate": false
        }
      }
    },
    {
      "schema": "public",
      "table": "big_json",
      "column": "json_data",
      "metadata": {
        "generatorId": "JsonMaskGenerator",
        "presetId": "JsonMaskGenerator",
        "pathExpression": "$[0].email",
        "jsonFilterTypes": [
          0
        ],
        "subGeneratorMetadata": {
          "presetId": "EmailGenerator",
          "generatorId": "EmailGenerator",
          "domain": "gmail.com",
          "excludedDomain": "",
          "replaceInvalidEmails": true,
          "isConsistent": false
        }
      }
    }
  ],
  "fallbackLinks": [
    {
      "schema": "public",
      "table": "big_json",
      "column": "json_data",
      "metadata": {
        "generatorId": "NullGenerator"
      }
    }
  ]
} 
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/generator-api-ref-json-mask.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
