Apidog Docs
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. References
  • Apidog Learning Center
  • Get started
    • Introduce Apidog
    • Basic concepts in Apidog
    • Navigating Apidog
    • Quick Start
      • Overview
      • Specify a new endpoint
      • Make a request to the endpoint
      • Add an assertion
      • Create a test scenario
      • Share your API documentation
      • Explore more
      • Send a request and save as an endpoint
    • Migration
      • Overview
      • Manual import
      • Scheduled import
      • Import options
      • Export data
      • Import from...
        • Import from Postman
        • Import OpenAPI (Swagger) spec
        • Import cURL
        • Import Markdowns
        • Import from Insomnia
        • Import from apiDoc
        • Import .har file
        • Import WSDL
  • Design APIs
    • Overview
    • Create a new API project
    • Endpoint basics
    • Components
    • Common fields
    • Global parameters
    • Endpoint change history
    • Batch endpoint management
    • Configure multiple request body examples
    • Schemas
      • Generate Schemas from JSON etc.
      • Build a schema
      • Overview
      • Create a new schema
    • Security schemes
      • Overview
      • Create a security scheme
      • Use the security scheme
      • Security scheme in online documentation
    • Advanced features
      • Custom endpoint fields
      • Import endpoints as test steps
      • Endpoint status
      • Appearance of parameter lists
      • Endpoint unique idenfication
  • Develop and Debug APIs
    • Overview
    • Generate requests
    • Send requests
    • Endpoint cases
    • Dynamic values
    • Validate responses
    • Design-first Mode & Request-first Mode
    • Generate code
    • Environments & variables
      • Overview
      • Using variables
      • Environments & services
    • Vault secrets
      • Overview
      • HashiCorp Vault
      • Azure Key Vault
      • AWS Secrets Manager
    • Pre/Post processors
      • Overview
      • Assertion
      • Extract variable
      • Wait
      • Database operations
        • Overview
        • MongoDB
        • Redis
        • Oracle Client
      • Using scripts
        • Overview
        • Postman scripts reference
        • Pre processor scripts
        • Post processor scripts
        • Public scripts
        • Calling other programming languages
        • Using JS libraries
        • Visualizing responses
        • Script examples
          • Assertion scripts
          • Using variables in scripts
          • Using scripts to modify request messages
          • Other examples
    • Dynamic values Modules
  • Mock API data
    • Overview
    • Smart mock
    • Custom mock
    • Mock priority sequence
    • Mock scripts
    • Cloud mock
    • Self-hosted runner mock
    • Mock language (Locales)
  • Automated tests
    • Overview
    • Test reports
    • Test scenarios
      • Create a test scenario
      • Pass data between requests
      • Flow control conditions
      • Import endpoints/endpoint cases from other projects
      • Sync data from endpoints/endpoint cases
      • Export test scenarios
    • Run test scenarios
      • Run a test scenario
      • Data-driven testing
      • Run test scenarios in batch
      • Scheduled tasks
      • Manage the runtime environment of APIs from other projects
    • Test APIs
      • Integration testing
      • Performance testing
      • End-to-end testing
      • Regression testing
    • Apidog CLI
      • Overview
      • Installing and running Apidog CLI
      • Apidog CLI Options
    • CI/CD
      • Overview
      • Integrate with Jenkins
      • Integration with Gitlab
  • Publish API Docs
    • Overview
    • API Technologies Supported
    • Quick share
    • View the API documentation
    • Publish docs sites
    • Folder tree settings
    • Custom layouts
    • Visibility settings
    • Endpoint SEO settings
    • Custom domain
    • Embedding values in document URLs
    • Documentation Search
    • Integrating Google Analytics with Doc Sites
    • CORS Proxy
    • API Versions
      • Overview
      • Create API versions
      • Publish API versions
      • Share endpoints with API versions
  • Send requests
    • Overview
    • gRPC
    • Use request proxy agents for debugging
    • SOAP/WebService
    • GraphQL
    • WebSocket
    • Socket.IO
    • SSE debugging
    • Create requests
      • Request History
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • HTTP/2
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apidog
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apidog
      • Create and send cookies
      • Debug requests
      • Save the request as an endpoint
  • Branches
    • Overview
    • Create a new sprint branch
    • Test APIs in a branch
    • Design API in a branch
    • Merge sprint branches
    • Manage sprint branches
  • Apidog MCP Server
    • Overview
    • Conntect API Specification within Apidog Project to AI via Apidog MCP Server
    • Conntect Online API Documentation Published by Apidog to AI via Apidog MCP Server
    • Conntect OpenAPI Files to AI via Apidog MCP Server
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apidog collaboration workflow
    • Managing authentication state in Apidog
  • Administration
    • Onboarding Checklist
      • Basic Concepts
      • Onboarding Guide
    • Managing Teams
      • Managing Teams
      • Managing Team Members
      • Member Roles & Permission Settings
      • Team Activities
      • Team Resources
        • General Runner
        • Team Variables
        • Request Proxy Agent
      • Real-time Collaborations
        • Team Collaboration
    • Managing Projects
      • Managing Projects
      • Managing Project Members
      • Notification Settings
      • Project Resources
        • Database Connection
    • Managing Organizations
      • Single Sign-On (SSO)
        • SSO Overview
        • Configure Microsoft Entra ID
        • Configure Okta
        • Configure SSO for an Organization
        • Managing user accounts
        • Mapping Groups to Teams
      • SCIM Provisioning
        • Intro to SCIM Provisioning
        • Microsoft Entra ID
        • Okta
      • Organization Resources
        • Self-hosted Runner
  • Billing
    • Overview
    • Credits
    • Unable to use credit cards?
    • Managing subscriptions
    • Upgrade plan
  • Add-ons
    • API Hub
    • Apidog Intellij IDEA plugin
    • Browser Extension
      • Chrome
      • Microsoft Edge
    • Request Proxy
      • Request proxy in Apidog web
      • Request proxy in shared docs
      • Request proxy in Apidog client
  • Account & preferences
    • Language settings
    • Data backup
    • Network proxy configuration
    • Hot keys
    • Updating Apidog
    • Generate OpenAPI access token
    • Deleting account
    • Account settings
  • References
    • API-Design First Approach
    • Apidog OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apidog flavored Markdown
  • Apidog Europe
    • Apidog Europe
  • Support Center
  1. References

JSONPath

JSONPath is a query language designed to extract information from JSON data structures, similar to how XPath functions for XML. The version of JSONPath utilized in Apidog is based on JSONPath Plus. For more detailed syntax explanations, you can follow the provided link.
If you are not familiar with JSONPath, you can use this free AI tool to generate expressions.

Quick Start#

1
JSON Response Example
Suppose we have the following JSON response:
{
    "store": {
      "book": [
        { "category": "fiction", "author": "Author A", "title": "Book 1" },
        { "category": "reference", "author": "Author B", "title": "Book 2" },
        { "category": "fiction", "author": "Author C", "title": "Book 3" }
      ]
    }
}
2
Extracting Data
To extract the title of the first book in the array, use this JSONPath expression:
 $.store.book[0].title
This expression returns "Book 1".
3
JSONPath Expression Explained
Let’s break down the expression$.store.book[0].title:
$: Refers to the root node of the JSON document β€” essentially the entire structure.
store: Points to thestoreproperty, which is an object under the root node.
book: Accesses thebookproperty under thestoreobject, which is an array.
[0]: Selects the first element in the book array (indices start at 0).
title: Retrieves thetitleof the first book in the array.
In summary, the expression navigates from the root, finds thestoreobject, accesses thebookarray, selects the first item, and extracts thetitleof that item.
πŸ’‘
JSONPath indices start from0.
Strings in JSONPath must use single quotes, for example: $.store.book[?(@.category=='reference')].

Syntax Overview#

Basic Syntax#

SyntaxDescription
$Root node
@Current node
.node or ['node']Access child nodes
[index]Array indexing, supports counting from 0
[start:end:step]Array slicing
*Wildcard, matches all child nodes
..Recursive wildcard, matches all descendants
(<expr>)Dynamic expression
?(<boolean expr>)Filter condition

Extended Syntax#

SyntaxDescription
^Access the parent of the matching item
~Get attribute names of the matching item (as an array)
@null(), @boolean(), @number(), @string(), @array(), @object()Retrieve basic JSON types
@integer()Retrieve integer type
@scalar()Retrieve complex types, accepting undefined and non-finite numbers (when querying JavaScript objects)
@other()Can be used with a user-defined otherTypeCallback
@undefined(), @function(), @nonFinite()Non-JSON types used when querying non-JSON JavaScript objects
@path, @parent, @property, @parentProperty, @rootShorthand selectors in filters
`Escape remaining sequences
@['...'], ?@['...']Escape special characters in attribute names within filters
$..Retrieve all parent components

JSONPath Examples#

Here are some common JSONPath expressions based on the example JSON data:

Example JSON Data:#

{
  "store": {
    "book": [
      {
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      {
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      {
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      {
        "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}

Example JSONPath Queries#

XPathJSONPathResult
/store/book/author$.store.book[*].authorAuthors of all books
//author$..authorAll authors
/store/*$.store.*All child nodes under store
/store//price$.store..priceAll price fields
//book[3]$..book[2]Third book (0-based index)
//book[last()]$..book[(@.length-1)] or $..book[-1:]Last book
//book[position()<3]$..book[:2] or $..book[0,1]First two books
//book[isbn]$..book[?(@.isbn)]Books with an ISBN
//book[price<10]$..book[?(@.price<10)]Books priced under 10
//*$..*Recursively match all child nodes
You can verify these expressions using a JSONPath tester. Make sure to select JSONPath Plus for validation.
jsonpath-plus-validation.png

References#

JSONPath Plus
JSONPath - XPath for JSON
Querying JSON with SelectToken
Modified atΒ 2025-02-19 09:48:29
Previous
Apidog OpenAPI/Swagger Specificaiton Extensions
Next
XPath
Built with