thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

JSON pointers: escaping

• 112 words • 1 min

RFC 6901: JSON Pointers:

JSON Pointer defines a string syntax for identifying a specific value within a JavaScript Object Notation (JSON) document.

I wanted to point out to a key named metadata -> annotations -> argocd.argoproj.io/tracking-id, wherein the arrows represent nesting.

There’s a problem: the slash (/) cannot be used as is, it needs to be escaped. And I always seem to forget how to escape it1.

Cheatsheet:

  • ~ -> ~0
  • / -> ~1

Real-world usage, from ArgoCD ignore differences:

spec:
  ignoreDifferences:
    [...]
    # Workaround for a sync loop in External Secrets: https://github.com/argoproj/argo-cd/issues/18980
    - kind: Secret
      namespace: argocd
      jsonPointers:
        - /metadata/annotations/argocd.argoproj.io~1tracking-id

  1. No, it’s not with a backslash (\/). That I can remember! ↩︎