# Run2 Scala JSON Navigation

> Improved JSON path navigation using Circe cursors in Scala.

- Skill: `cxcscmu/run2-scala-json-navigation` (Agent Skill)
- Install (CLI): `npx get-skill add cxcscmu/run2-scala-json-navigation`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cxcscmu/run2-scala-json-navigation/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: cxcscmu (https://skillmd.com/u/cxcscmu)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/cxcscmu/run2-scala-json-navigation

---


# Circe JSON Navigation

`io.circe.ACursor` provides a robust way to navigate JSON structures.

## Path Extraction
```scala
import io.circe.Json
import io.circe.syntax._

def navigatePath(json: Json, path: String): Option[Json] = {
  val parts = path.split('.')
  parts.foldLeft(Option(json.hcursor)) { (cursor, part) =>
    cursor.flatMap { c =>
      // Try treating part as object key
      val downField = c.downField(part)
      if (downField.succeeded) Some(downField)
      else {
        // Try treating part as array index
        Try(part.toInt).toOption.flatMap { idx =>
          val downN = c.downN(idx)
          if (downN.succeeded) Some(downN) else None
        }
      }
    }
  }.flatMap(_.focus)
}
```

## JSON Tokenization
- Use `noSpaces` for compact token.
- Use `spaces2` for pretty token.
- Circe natively handles recursive `Json` objects.

