> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# json.getPath

> Dotted string path または array table of keys を使って table から nested value を読みます。

<div className="real-function-page">
  ```lua theme={null}
  json.getPath(object: table, path: string | table, defaultValue?: any): any | nil
  ```

  ## エイリアス

  * `json.getpath`

  ## 引数

  <ParamField path={"object"} type={"table"} required>
    読み取り元の root table。function はこの argument が table であることを要求します。
  </ParamField>

  <ParamField path={"path"} type={"string | table"} required>
    たどる path。string は dots で split されます。integer string tokens は raw array indexing で読まれます。table path は 1 から #path までの array entries を keys として使います。
  </ParamField>

  <ParamField path={"defaultValue"} type={"any"}>
    Traversal が path 完了前に nil または non-table に到達した場合に返す fallback value。
  </ParamField>

  ## 戻り値

  <ResponseField name={"pathValue"} type={"any | nil"}>
    Requested path の value。path が missing の場合、defaultValue が提供されていればそれを返し、それ以外は nil を返します。
  </ResponseField>

  ## 例

  Dotted string path または array table of keys から nested table value を読みます。

  ```lua theme={null}
  local document = {
      user = {
          profile = { name = "Guest" },
          items = { "first", "second" },
      },
  }

  local name = json.getPath(document, { "user", "profile", "name" }, "Unknown")
  local second = json.getPath(document, "user.items.2")

  print(name)
  print(second)
  ```
</div>
