Issue Report
When using the JsonFieldPatternBuilder to mask sensitive data within a nested JSON structure, the resulting output is not in a valid JSON format.
Sample code
public class EJMaskTest {
static {
EJMaskInitializer.addFilter(
new BaseFilter(JsonFieldPatternBuilder.class, 4, "innerKey1")
);
}
public static void main(String[] args) throws JsonProcessingException {
String input = "{\"outer\":\" {\\\"innerKey1\\\": \\\"191287127167167\\\",\\\"innerKey2\\\":\\\"testInnerInformation\\\"}\"}";
String output = EJMask.mask(input);
System.out.println(input);
System.out.println(output);
}
}
Below is the output
{"outer":" {\"innerKey1\": \"191287127167167\",\"innerKey2\":\"testInnerInformation\"}"}
{"outer":" {\"innerKey1\": \"1912-xxxx",\"innerKey2\":\"testInnerInformation\"}"}
Expected Behavior
The expected output should mask only the innerKey1 value from 191287127167167 to 1912-xxxx, while leaving all other content unchanged. The correct output should be:
{"outer":" {\"innerKey1\": \"1912-xxxx\",\"innerKey2\":\"testInnerInformation\"}"}
Actual Behavior
The actual output is:
{"outer":" {\"innerKey1\": \"1912-xxxx",\"innerKey2\":\"testInnerInformation\"}"}
There is a missing escape character (backslash) following 1912-xxxx, which results in an invalid JSON format.
Steps to Reproduce the Issue
- Use the code provided in the "Sample Code" section.
- Observe the output.
Issue Report
When using the JsonFieldPatternBuilder to mask sensitive data within a nested JSON structure, the resulting output is not in a valid JSON format.
Sample code
Below is the output
Expected Behavior
The expected output should mask only the innerKey1 value from 191287127167167 to 1912-xxxx, while leaving all other content unchanged. The correct output should be:
Actual Behavior
The actual output is:
There is a missing escape character (backslash) following 1912-xxxx, which results in an invalid JSON format.
Steps to Reproduce the Issue