# Paths

> The paths that --get, set and the MCP tools take: protobuf field numbers, DER indices, map keys, JWT parts, JSON text, and paths that cross formats.

- Protobuf: field numbers separated by `.`; `N[i]` picks the i-th occurrence
  (`1.3[2].4`). A LEN field is entered through its best `message` alt.
- DER: 0-based child indices separated by `.`; the first segment indexes the
  top-level elements, so `0.0.6` is a certificate's subjectPublicKeyInfo.
  For a PEM bundle the first segment picks the block, so `1.0.0.5` is the
  second certificate's subject (`is_der` is true only when every block is DER).
  Encapsulating BIT/OCTET STRINGs are entered like constructed elements.
- CBOR / MessagePack: map keys / array indices separated by `.`
  (`users.0.name`). A segment matches a text key exactly, indexes an array, or
  matches an integer map key; CBOR tags are followed transparently and a
  multi-item sequence is indexed by the first segment. `--format raw` writes a
  `bytes` value's bytes, an `ext` value's data, or a `text` value's UTF-8.
- JWT: a part name (`header`, `payload`, `signature`; for a JWE `header`,
  `encrypted_key`, `iv`, `ciphertext`, `tag`) or its index, optionally
  followed by object keys / array indices into that part's JSON
  (`payload.sub`, `payload.roles.0`, `header.alg`). Keys match exactly after
  unescaping; the first of duplicate keys wins; keys containing `.` can't be
  addressed. The part must be strictly valid JSON (RFC 8259). Output:

  ```jsonc
  { "part": "payload", "index": 1, "node": Node }          // a whole part
  { "part": "payload", "index": 1, "path": "sub",
    "range": [7, 13],                                       // in the part's decoded text
    "value": "1234" }                                       // the JSON value, verbatim
  ```

  `value` is copied from the token, so its numbers are not re-encoded (a large
  integer stays a JSON number). `--format raw` writes a string's unescaped
  text, any other value's JSON, or a whole part's decoded bytes; `--format
  tree` prints `payload.sub = "1234"`.
- JSON text: when the path reaches text that is a JSON object or array (a
  decoded text layer such as base64 → gzip → JSON, a protobuf string field, or
  a CBOR/MessagePack text string), the remaining segments are object keys /
  array indices into it, with the same matching rules as JWT JSON
  (`users.37.id`, `2.config.region`). The whole decoded text is read, not the
  truncated preview. A bare JSON scalar (`"42"`) is text, not walked. Output:

  ```jsonc
  { "path": "users.37.id",                                  // within the JSON text
    "range": [3263, 3268],                                  // in that text
    "value": 10437 }                                        // the JSON value, verbatim
  ```

  `--format raw` and `--format tree` work as for JWT JSON (`users.37.id =
  10437`). Values inside JSON text are not editable.
- Text layers are descended automatically. `--format raw` writes the payload:
  a field's bytes, or a primitive element's content (a BIT STRING without its
  unused-bits byte).
- `--format raw` without `--get` writes the innermost layer's whole bytes:
  the decoded bytes of the last text or compression layer (hex, base64, PEM,
  dump, gzip, zlib, zstd), or the input itself when there is no such layer.
  So base64 → gzip → text writes the full text, past the 1024-char preview.
- **Paths cross formats.** When the next segment cannot descend in the
  current format but the item holds a decoded node, the rest of the path
  continues in that node's format: a protobuf string or bytes alt's
  `decoded` node, a CBOR/MessagePack byte string's `decoded` node, or a JWT
  part that is not JSON. So `2.0.0.5` is the subject of a base64 (or raw DER,
  or PEM) certificate in protobuf field 2, `cert.0.0.5` the same in a CBOR
  map, `3.payload.sub` a claim of a JWT in a string field, and `p.1` a field
  of protobuf in a byte string. Descent within a format always wins, so a
  single-format path keeps its meaning. The result is printed in the
  selected item's own schema (Field, Element, Value, the JWT form or the
  JSON form), with
  ranges in the buffer of the node it was found in. `bytepeel set` paths
  cross formats the same way.
