docs
  • README
  • John's Notes and Documentation
    • Linux
      • Distributions
        • Arch Linux
          • Common Applications
          • Setting up pacaur with the Arch User Repository
          • Bluetooth
          • Hibernate
          • Graphical Configuration
          • libvirt
          • Post Install Tasks
            • Time
            • Reflector
            • SMTP
            • ZFS Configuration
            • smart
            • nfs
            • Package Management
              • aurutils
            • Programming Languages
              • nodejs
              • ruby
            • Restore Installed Applications
            • User Configuration Management
            • User Namespaces
            • Gaming with Wine
            • ZFS Dataset Structure
            • Raspberry PI Secure VPN Torrentbox
        • NixOS
          • Remotely Accessing Install Media
          • root on ZFS Install
      • systemd
        • Network Bonding
      • Tuning
        • CPU Tuning
        • Limits
        • Sysctls
        • Network Reliability With iwlwifi
        • Surface Pro 4 Power Tuning
        • ZFS Arc Max on Linux
      • TrueNAS
        • Setup
  • BSD
    • FreeBSD
      • iocage
      • Poudriere in a bhyve VM
    • FreeNAS
      • Copy SSH Keys off FreeNAS
      • FreeNAS Service jails
      • iocage Service jails
        • Couchpotato jail
        • Deluge jail
        • Emby jail
        • Poudriere WebUI jail
        • Podcatcher jail
        • Sabnzbd jail
        • Sickrage jail
        • Syncthing jail
        • Duplicity jail
        • Lets Encrypt jail
      • Wrong Version jail
    • pfSense
      • Sending Specific Traffic Through OpenVPN
  • Desktop and Userspace
    • Gaming
      • Grim Dawn
      • Path of Exile
    • Internet
      • Re-authenticate IRC Nickname
      • Lightdm VNC Connection with Password
    • Media
      • Convert Audio to Video
      • Convert Text to Speech
  • System Administration
    • Security
      • GPG Subkeys
    • Shell Scripting
      • dd
      • find
      • rsync
      • vim
    • ZFS
      • Mirrors
  • Certifications
    • CKA
      • Core-Concepts
      • Scheduling
      • Logging
      • Application Lifecycle Management
      • Cluster Maintenance
      • Security
      • Storage
      • Networking
      • Install Kubernetes with kubeadm
      • JSON PATH
Powered by GitBook
On this page
  • Dictionaries
  • Lists
  • Criteria
  • Wildcards
  • JSON PATH in Kubernetes
  1. Certifications
  2. CKA

JSON PATH

Query language for json

Dictionaries

$ is root element.

{
    "car": {
        "price": "$25,000"
    }
}

Query price via $.car.price:

[ "$25,000" ]

Lists

[
    1,
    2,
    3
]

Query via $[INDEX]:

$[0] is [1]

can do multiple: [0,2] is [1,3]

Can slice via [START:END_EXCLUSIVE] Can step via [START:END_EXCLUSIVE:STEP] Can get last via [-1] or [-1:]

Criteria

More complex queries

[
    1,
    2,
    3,
    4
]

?() for query.

@ each item in list

So, get items > 2:

$[ $( @ > 2) ]`

Result: [3,4]

Can use ==, !=, in, nin

Can check strings via ?(@.SOME_KEY == "val")

Wildcards

We can also use wildcards, eg all matches:

$[*].price

Or with Dictionaries:

$*.car

JSON PATH in Kubernetes

kubectl get pods -o=jsonpath='{ .item[0].spec }'

$ is added if not there.

We can combine queries for multiple results:

kubectl get pods -o=jsonpath='{ .item[0].spec }{ .items[*].metadata }'

We can prettify via { "\n" } between queries.

We can loop with a {range .items[*]}{ ... }{ end }, and access internal elements inside.

Can also create custom columns via -o=custom-columns=COL_NAME:JSON_PATH

PreviousInstall Kubernetes with kubeadm

Last updated 4 months ago