NIAOJoin Beta
Ecosystem

json

available

JSON Parse & Manipulate

Core Standard Library

Overview

The json module is what you use for config files, API payloads, and log lines. Parse a string into a mutable tree, change values, stringify back out. Nested keys are reachable with dot paths like user.address.city so you don't write three levels of bracket indexing.

merge combines two objects recursively (handy for default config + overrides), and clone copies a subtree without shared references.

  • parse & stringify
  • Dot-path access
  • Deep merge
  • Pretty-print

Import

import
import "json"

Quick start

quick start
import "json"
let data = json.parse('{"user": {"name": "Niao", "tags": ["fast"]}}')
json.set(data, "user.tags.1", "lean")
print(json.stringify(data, { pretty: true }))

Capabilities

High-level overview of what json is for.

parse & stringify

Turn JSON text into Niao values and back. stringify accepts a pretty flag for indented output.

Nested path access

get and set by dot path, user.settings.theme instead of chaining ["user"]["settings"]["theme"].

Deep merge & clone

merge walks both objects and combines keys; clone duplicates a value tree for safe mutation.

Pretty-print

Indented stringify for configs and debug dumps you actually want to read.

API reference

15 functions and methods in json. Grouped by category from the standard library docs.

Namespace API (recommended)

SignatureDescription
json.parse(text)Parse JSON string → value
json.stringify(value)Compact JSON text
json.stringify_pretty(value, indent?)Pretty-print (default indent `2`)
json.valid(text)`true` if text is valid JSON
json.type(value)`"null"`, `"bool"`, `"number"`, `"string"`, `"array"`, `"object"`
json.is_json(value)Whether value can be serialized to JSON
json.keys(object)Sorted key list
json.has(object, key)Key exists
json.get(value, path)Nested read - e.g. `"user.items[0].id"`
json.set(object, path, value)Set nested field in place
json.merge(target, source)Deep-merge objects into `target`
json.clone(value)Deep copy
json.equal(a, b)Deep equality
json.array_len(array)Array length
json.object_len(object)Object field count

Related libraries

More from Core Standard Library.

available

io

File & Path I/O

Read and write files, stream large inputs, and work with paths. Blocking I/O can run on background threads.

  • Whole-file read/write
  • Streaming handles
  • Background I/O
  • Path helpers
Read more
available

time

Wall-Clock & Time Zones

Timestamps, formatting, parsing, and time zones. Built on chrono and chrono-tz, DST handled correctly.

  • IANA time zones
  • strftime formats
  • Datetime values
  • Date math
Read more
available

re

Regular Expressions

Regular expressions via Rust's regex crate. Match, split, replace, and compile patterns once for hot loops.

  • Capture groups
  • Search & replace
  • Compiled patterns
  • Unicode-aware
Read more