Module

std::json

JSON

JSON serialization front-end for the shared std::serializer contracts.

Overview

The Json namespace configures Serializer::Writer for JSON object syntax and exposes writeRoot overloads for scalar and Serialize values. Output is appended to a caller-provided String.

JSON is the permissive front-end for the shared serializer: scalar document roots are allowed, field names are always quoted, and record entries are separated with commas.

  Json::writer()
  ┌──────────────────────────────────────────────┐
  │ recordPrefix: "{"                            │
  │ recordSuffix: "}"                            │
  │ entrySeparator: ","                          │
  │ fieldSeparator: ":"                          │
  │ supportsScalarRoot: true                     │
  │ quoteFieldKeys: true                         │
  └──────────────────────────────────────────────┘

APIs

Function Description
Json::writer JSON writer configuration
Json::writeRoot Serialize a root scalar or Serialize value

Notes

JSON supports scalar roots, quotes field keys, and uses comma-separated object entries. String escaping is provided by the shared serializer helpers. writeRoot appends to the provided output string, while stringify creates a fresh output string and returns it.

Root Shapes

Root value Supported Notes
Boolean, number, char, string Yes Uses scalar overloads
T: Serialize Yes Uses record serialization
Arrays No No generic array writer yet

Example

import Json from "std::json";
import String from "std::string";

function main(): i32 {
  let mut output: String = String::create("");
  Json::writeRoot(&output, true);
  return 0;
}
namespace Json

JSON serialization front-end built on std::serializer.

The namespace exposes the JSON writer configuration plus convenience helpers for writing scalar and serializable roots into String buffers.

Functions

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function stringify<T>(value: &T): Result<String, Error>

Serializes a Serialize record-like value into a fresh JSON string.

The value controls field order and nested output through its Serialize implementation. JSON writer settings quote field keys and wrap records with { and }.

function writer(): Writer

Returns the JSON serializer writer configuration.

The writer quotes all field keys and permits scalar root values. Callers normally use Json::writeRoot or Json::stringify instead of constructing this writer directly.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.

function writeRoot(output: &mut String, value: &String): Result<boolean, Error>

Appends an owned string JSON document root to output.