public class PathBasedFieldMasker extends Object implements FieldMasker
Values for paths that match a given path string will be replaced with a given mask string.
For example, given the following JSON:
{
"aaa": {
"bbb": [
{
"ccc": "ddd"
}
]
},
"bbb": [
{
"eee": "fff"
}
]
}
Then the following matches occur:
/aaa matches { "bbb" : [ { "ccc" : "ddd" } ] }/aaa/bbb matches [ { "ccc" : "ddd" } ]/aaa/bbb/0/ccc matches "ddd"For example, given the following JSON:
{
"aaa": {
"bbb": [
{
"ccc": "ddd"
}
]
},
"bbb": [
{
"eee": "fff"
}
]
}
Then the following matches occur:
aaa matches { "bbb" : [ { "ccc" : "ddd" } ] }aaa/bbb matches [ { "ccc" : "ddd" } ]aaa/bbb/0/ccc matches "ddd"bbb matches [ { "ccc" : "ddd" } ] and [ { "eee" : "fff" } ]bbb/0/ccc matches "ddd"0/ccc matches "ddd"ccc matches "ddd"FieldNameBasedFieldMasker instead.
A single FieldNameBasedFieldMasker configured with many field names,
is much more efficient than having a PathBasedFieldMasker per field name.
For example, given the following JSON:
{
"aaa": {
"bbb": {
"ccc": "ddd"
},
"eee": {
"ccc": "hhh",
},
},
"iii": {
"jjj": {
"ccc": "lll"
},
},
"ccc": "mmm"
}
Then the following matches occur:
aaa/*/ccc matches "ddd" and "hhh"*/ccc matches "ddd" and "hhh" and "lll"| Modifier and Type | Field and Description |
|---|---|
static String |
TOKEN_SEPARATOR |
static String |
WILDCARD_TOKEN |
| Constructor and Description |
|---|
PathBasedFieldMasker(String pathToMask,
Object mask) |
| Modifier and Type | Method and Description |
|---|---|
Object |
mask(JsonStreamContext context)
If the field at the JSON stream context's current path should be masked,
then returns the masked value to write as the field's value.
|
public static final String TOKEN_SEPARATOR
public static final String WILDCARD_TOKEN
public Object mask(JsonStreamContext context)
FieldMaskerMaskingJsonGenerator will write the returned masked value
as the field's value (instead of the original field's value).
If the JSON stream context's current path should NOT be masked, returns null.
mask in interface FieldMaskercontext - the current JSON stream context, which can be used to determine the path within the JSON output.NullNode.instance.
To write , the return MaskingJsonGenerator.MASKCopyright © 2013–2021. All rights reserved.