---
keyword: [Extend, PMD Scripting, Scripts]
nav: wcp_docs
parent_url: /wcp_docs/
title: query (source, jsonPath)
layout: subsection
---

## Description

Evaluates a JSONPath expression for the JSON structure specified by `source`.

Equivalent to `json:query(source, jsonPath, true)`.

## <a id="section_1"></a>Return Type

`List`

## <a id="section_2"></a>Namespace Function Syntax

```
json:query(source, jsonPath)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>source</td><td>String or object. If object, the function first converts it to a string via json:stringify(). If string, must be a valid JSON string.</td></tr><tr><td>jsonPath</td><td>A JSONPath expression to evaluate in the source.</td></tr></tbody></table><br/>

<b>Example</b>

Sample JSON `source`:

```
{
    "data": [
        {
        "managers": [
            {
            "descriptor": "Joy Banks",
            "id": "1f8ff0a1f91410f6cb260e1be5fe0b91"
            }
        ],
        "name": "Human Resources",
        "descriptor": "Human Resources",
        "Organization_Reference_ID": "SUPERVISORY_Human_Resources",
        "id": "e02485f863ec48d39a082bb95cc4abe4",
        "inactive": false
        },
        {
        "managers": [
            {
            "descriptor": "Rachel Knight",
            "id": "6e591f742bee10f68b30693a25690838"
            }
        ],
        "name": "Finance & Administration",
        "descriptor": "Finance & Administration",
        "id": "1ad7d37487904a989b2db1bfa6fed57d",
        "inactive": true
        },
        {
        "managers": [
            {
            "descriptor": "Oliver Reynolds",
            "id": "3895af7993ff4c509cbea2e1817172e0"
            }
        ],
        "name": "Information Technology",
        "descriptor": "Information Technology",
        "Organization_Reference_ID": "SUPERVISORY_Information_Technology",
        "id": "e50d309a6d8540e3b533219cfa2c330b",
        "inactive": false
        },
        {
        "managers": [
            {
            "descriptor": "Joey Kowalski",
            "id": "34b0032b9a364693bc8db18b018d5725"
            }
        ],
        "name": "Sales",
        "descriptor": "Sales",
        "id": "50577df7ae5c4292a969e8a64c8650ed",
        "inactive": true
        },
        {
        "managers": [
            {
            "descriptor": "Yumiko Sato",
            "id": "747a437151ae4b339faa1bcf79192c8f"
            }
        ],
        "name": "Marketing",
        "descriptor": "Marketing",
        "id": "f62f2721e8194dfc9c6feb74cd8eb271",
        "inactive": false
        },
        {
        "managers": [
            {
            "descriptor": "John Chen",
            "id": "c97ff008445c4f6288e53423570f27da"
            }
        ],
        "name": "Legal",
        "descriptor": "Legal",
        "id": "4b2ad0373fdb4f8499ee843df7cf11a8",
        "inactive": false
        }
    ]
}
```

Sample `json:query(source, jsonPath)` statements and results:

<table><thead><tr><th>Statement</th><th>Result</th></tr></thead><tbody><tr><td>json:query(supervisoryOrganizations, '$.data[*].name')</td><td>["Human Resources","Finance & Administration","Information Technology","Sales","Marketing","Legal"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$.data[0].name')</td><td>["Human Resources"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$..data[0].name')</td><td>["Human Resources"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$.data[:2].name')</td><td>["Human Resources","Finance & Administration"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$.data[3,4].name'</td><td>["Sales","Marketing"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$.data[?(@.inactive==true)].descriptor')</td><td>["Finance & Administration","Sales"]</td></tr><tr><td>json:query(supervisoryOrganizations, '$.data[?(@.Organization_Reference_ID)].descriptor')</td><td>["Human Resources","Information Technology"]</td></tr></tbody></table><br/>

### Related Information

[JSONPath Support in PMD Scripting](/wcp_docs/GUID-34d92936-0ac0-4a89-b7df-19a7169f9c14-enHYPHENus.html)

