← All procedures

json.query

Find the values at a JSON Pointer or a path in a JSON value

MCPCLI
Package
@procedures/json · README
Path
["json","query"]
CLI
mark json query --value <any>
MCP tool
json.query on the dev-tools server
As data
{"$proc":["json","query"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/json/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["json","query"], { value: "<value>" });
console.log(JSON.stringify(result));

From the command line

$ mark json query --value <any>

As data, in a program

{ "$proc": ["json", "query"], "input": { "value": "<value>" } }

Input

FieldTypeRequiredDefaultDescription
valueanyyesThe JSON value to search
pointerstringnoA JSON Pointer (RFC 6901), for example /items/0/name. Give pointer or path
pathstringnoA path query, for example items[*].name or $..id. Give pointer or path

Output

FieldTypeRequiredDefaultDescription
foundbooleanyesTrue when one or more values match
valueanynoThe value of the first match
matchesobject[]yesEach match, in document order
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "value": {
        "description": "The JSON value to search"
      },
      "pointer": {
        "description": "A JSON Pointer (RFC 6901), for example /items/0/name. Give pointer or path",
        "type": "string"
      },
      "path": {
        "description": "A path query, for example items[*].name or $..id. Give pointer or path",
        "type": "string"
      }
    },
    "required": [
      "value"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "found": {
        "type": "boolean",
        "description": "True when one or more values match"
      },
      "value": {
        "description": "The value of the first match"
      },
      "matches": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "pointer": {
              "type": "string",
              "description": "The JSON Pointer of the match"
            },
            "value": {
              "description": "The value of the match"
            }
          },
          "required": [
            "pointer",
            "value"
          ],
          "additionalProperties": false
        },
        "description": "Each match, in document order"
      }
    },
    "required": [
      "found",
      "matches"
    ],
    "additionalProperties": false
  }
}