JSON structure
In the context of data masking, a JSON file can be uploaded and used to specify which data fields (e.g. PII) should be masked to protect sensitive information. Accurately constructing a JSON file for data masking involves understanding the structure of JSON, knowing what fields need masking, and correctly using JSON Path syntax to specify those fields.
Understanding JSON structure
JSON data is presented in name/value pairs, with fields and values enclosed within curly braces {}
for objects or square brackets []
for lists. Each data element within an object is separated by a comma. The correct format must be used; otherwise, it can result in errors during the masking process.
Definitions
Groups/fields: Only specify fields that require masking. Fields not mentioned will not be masked. The presence of the field is vital; its value can be
null
since it is not relevant to the masking process—this means the value is merely a placeholder.Objects: In JSON, an object is a collection of key-value pairs where each key (or field) is a string, and the value can be a string, number, boolean, array, object, or null. Objects are delineated by curly braces
{}
. Each key-value pair in an object is separated by a comma, and the key and value in each pair are separated by a colon.Lists (Arrays): In JSON, an array is an ordered list of values. An array begins with a left square bracket
[
and ends with a right square bracket]
. The values in the array are separated by commas and can include any data type—strings, numbers, objects, other arrays, etc. Arrays do not associate values with keys.Fields: In the context of JSON, fields refer to the names in key-value pairs within an object. Fields act as identifiers and are always strings. Each field in an object should be unique within that object. Fields provide a way to access the values they are associated with.
Values: Values in JSON can be of any data type: strings, numbers, objects, arrays, booleans, or null. Values are the data assigned to fields in objects or the elements within an array. They represent the actual data contained within the JSON structure.
Example 1: List format with null values
[
{
"First_Name": "John",
"Last_Name": "Doe",
"DOB": "1968-11-24",
"SSN": "123-45-6789",
"Address": "123 4th Ave",
"City": "Allentown",
"State": null,
"Zipcode": null
}
]
Example 2: Object format with null values
{
"First_Name": "John",
"Last_Name": "Doe",
"DOB": "1968-11-24",
"SSN": "123-45-6789",
"Address": "123 4th Ave",
"City": "Allentown",
"State": null,
"Zipcode": null
}
Understanding JSON path
A JSON Path allows you to specify and locate specific parts of a JSON document. The syntax includes a variety of operators and expressions, but at its most basic, it starts with $
to represent the root object or element.
The
$
symbol denotes the root element of the JSON document.['FieldName']
targets a specific field by name.
File format XPath examples
For Example 1 (List format):
$[*]['First_Name']
targets the "First_Name" field of each object in the list.
For Example 2 (Object format):
$['First_Name']
directly targets the "First_Name" field in the root object.
JSON file formats
When profiling and masking JSON files, file formats must be provided to determine the JSON structure of the data file. To prevent overloading the masking engine, uploading a file format that only contains the necessary JSON structure is suggested. Only one record per JSON structure is needed. An example of a JSON file format and data file pair is below.
Example JSON file format
[
{
"id": 1,
"name": {
"first": "Alex",
"last": "Johnson"
},
"address": {
"street": "Main Street",
"city": "Albany",
"state": "MA",
"zip": 04739
}
}
]
Example JSON data file
[
{
"id": 1,
"name": {
"first": "Jay",
"last": "Green"
},
"address": {
"street": "Jaeg Highway",
"city": "Nacihju",
"state": "NV",
"zip": 24077
}
},
{
"id": 2,
"name": {
"first": "Lottie",
"last": "Bush"
},
"address": {
"street": "Cacdol Key",
"city": "Buwiju",
"state": "OK",
"zip": 86168
}
},
{
"id": 3,
"name": {
"first": "Henry",
"last": "Rice"
},
"address": {
"street": "Suvek Turnpike",
"city": "Dennelema",
"state": "IN",
"zip": 48587
}
}
]
The JSON file format contains the JSON structure and fields to profile all of the records in the data file.