Chapter 5

Text, JSON, and CSV

Process UTF-8 text, regular expressions, and structured data.

JSON pipelines

example.hhy
read_text(path("users.json"))
    |> parse_json
    |> get("users")
    |> stream
    |> where { user -> user.active == true }
    |> collect
    |> encode_json({ pretty: true })
    |> save_text(path("active-users.json"))

The strict JSON parser rejects duplicate keys, invalid Unicode surrogates, and non-finite numbers. Map encoding remains deterministic.

Text and CSV

  • contains, starts_with, ends_with, trim, split, join, replace, lower, and upper
  • PCRE2 regex literals and named captures
  • Streaming CSV records with header, delimiter, and quote options
  • Strings always validate UTF-8 and may contain embedded U+0000