Search code examples
jsonpath

Safe navigation operator in JSONPath?


Ruby and many languages support safe navigation operator:

name = article&.author&.name

Is there any equivalent in JSONPath?


Solution

  • This is unnecessary in JSON Path. Navigation is safe by default. If a value doesn't exist at a given path, the node set returned will just be empty; it shouldn't error.

    This may, of course, vary between implementations as we don't have a standard yet, but we're working on one.