Files
Brandon Lucas 3df037cebb feat: initialize Lux package registry
- Add registry README with API documentation
- Add initial packages: json, http-client, testing
- Add package index.json for registry server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 04:35:00 -05:00
..
2026-02-15 04:35:00 -05:00
2026-02-15 04:35:00 -05:00

json

JSON parsing and serialization utilities for Lux.

Installation

lux pkg add json 1.0.0

Usage

import json

// Parse JSON string
let data = json.parse('{"name": "Alice", "age": 30}')

// Get fields
let name = json.getString(data, "name")  // Some("Alice")
let age = json.getInt(data, "age")       // Some(30)

// Nested paths
let city = json.getPath(data, "address.city")

// Create JSON
let obj = json.object([
    ("name", JsonString("Bob")),
    ("active", JsonBool(true))
])

// Stringify
let str = json.stringify(obj)  // '{"name":"Bob","active":true}'

API

Function Description
parse(s) Parse JSON string
stringify(v) Convert to JSON string
getString(obj, key) Get string field
getInt(obj, key) Get integer field
getPath(obj, path) Get nested field by dot path
isNull(v) Check if value is null
object(pairs) Create JSON object
array(items) Create JSON array
prettyPrint(v) Pretty-print with indentation

License

MIT