Class JsonPath

java.lang.Object
dev.blaauwendraad.masker.json.path.JsonPath

public class JsonPath extends Object
A JsonPath expression is used to traverse, select and extract fields and values from a JSON document.

Example JSON and corresponding paths:

 {
     "a": "1",
     "b": {
         "c": "2"
     },
     "d": [
          {
              "e": "3",
              "f": "4"
          },
          {
              "g": "5"
          }
     ]
 }
 
In the context of this library, any JsonPath starts with a '$' symbol, which denotes the root node. Then, access to nested JSON objects is denoted by a dot ('.') followed by a String name selector which denotes the key of the nested object. Furthermore, a numeric index selector (e.g. 3) selects an indexed child of an array. So, considering the example JSON above:
  • $.a = "1"
  • $.b.c = "2"
  • $.d[0].e = "3"
  • $.d[0].f = "4"
  • $.d[1].g = "5"
These are all the parts of JSONPath considered for this library, to be able to denote a target key matching one and only one value in the JSON document to be masked. This is useful in cases where the same JSON key appears multiple times in the same JSON document (i.e. in different objects).
  • Method Details