Examples of JSONPath-Based Anonymization Rules
This section includes examples of commonly used JSONPath-based anonymization rules.
Example 1: Rule with nested JSON elements
Rule definition example:
{ "name": "NESTED_JSONPATH_RULE_1", "rule_id": "JSONPATH", "paths": ["$.configs.properties.passwd"], "include_files": ["*config.json"], "shared": true }
Input data:
{ "configs": { "properties": { "user": "abc", "passwd": "12!@" } } }
Output data (after anonymizarion):
{ "configs": { "properties": { "user": "abc", "passwd": "¶91!@¶" } } }
Example 2: Rule with indexed JSON array objects
Rule definition example:
{ "name": "ARRAY_JSONPATH_RULE", "rule_id": "JSONPATH", "paths": ["$.configs.properties[1].passwd"], "include_files": ["config.json"], "shared": true }
Input data:
{ "configs": { "properties": [ { "database": "mysql", "url": "user@host:port" }, { "user": "abc", "passwd": "12!@" } ] } }
Output data (after anonymization):
{ "configs": { "properties": [ { "database": "mysql", "url": "user@host:port" }, { "user": "abc", "passwd": "¶91!@¶" } ] } }
Example 3: Rule with JSON map
Rule definition example:
{ "name": "MAP_JSONPATH_RULE", "rule_id": "JSONPATH", "paths": ["$.properties.passwd"], "include_files": ["*config.json"], "shared": true }
Input data:
{ "db":"mysql", "properties": { "user_name":"sa", "passwd":"sa_pass" }, "pooli_size":32, "timeout":10 }
Output data (after anonymization):
{ "db": "mysql", "properties": { "user_name": "sa", "passwd": "¶vm_wtto¶" }, "pooli_size": 32, "timeout": 10 }
Example 4: Rule to mask all JSON objects from list
Rule definition example:
{ "name": "ALL_FROM_ARRAY_JSONPATH_RULE", "rule_id": "JSONPATH", "paths": ["$.configs.properties[*].passwd"], "include_files": ["*config.json"], "shared": true }
Input data:
{ "configs": { "properties": [ { "user": "abc1", "passwd": "pass1" }, { "user": "abc2", "passwd": "pass2" } ] } }
Output data (after anonymization):
{ "configs": { "properties": [ { "user": "abc1", "passwd": "¶smfz7¶" }, { "user": "abc2", "passwd": "¶smfz8¶" } ] } }