summaryrefslogtreecommitdiff
path: root/docs/std/json.md
diff options
context:
space:
mode:
authorczjstmax <jstmaxlol@disroot.org>2026-01-31 15:10:20 +0100
committerGitHub <noreply@github.com>2026-01-31 15:10:20 +0100
commitd2e2617dec584884b92eb452f377b20c0bf8f321 (patch)
treed7cdc28d1a83f16a0fc7e945963aa070bfa9d3e4 /docs/std/json.md
parent0427d254207a69e394499d1abaea768f484f1cb5 (diff)
parent051400c70a4d5384923113cfbcbc69e8e58d27a0 (diff)
Merge pull request #1 from z-libs/main
Merge newer updates
Diffstat (limited to 'docs/std/json.md')
-rw-r--r--docs/std/json.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/std/json.md b/docs/std/json.md
index fba2ad8..ce35d64 100644
--- a/docs/std/json.md
+++ b/docs/std/json.md
@@ -51,6 +51,32 @@ Represents a node in a JSON document.
- **`fn at(self, index: usize) -> Option<JsonValue*>`**
Retrieves a value from an array by index.
+#### Serialization
+
+- **`fn to_string(self) -> String`**
+ Serializes the JSON value to a string representation.
+
+- **`fn stringify(self, buf: String*)`**
+ Internal recursive serialization method that appends to a string buffer.
+
+**Example:**
+```zc
+let obj = JsonValue::object();
+obj.set("name", JsonValue::string("Alice"));
+obj.set("age", JsonValue::number(30.0));
+
+let json_str = obj.to_string();
+println "{json_str.c_str()}"; // {"name":"Alice","age":30}
+json_str.free();
+obj.free();
+```
+
+**Features:**
+- Proper escaping of special characters: `\"`, `\\`, `\n`, `\t`, `\r`, `\b`, `\f`
+- Numbers formatted with `%.15g` for precision
+- Recursive serialization for nested objects and arrays
+- Round-trip compatible with `parse()`
+
#### Memory Management
- **`fn free(self)`**