Module serde_json::builder [] [src]

JSON Builders

This module provides Builders that simplify constructing complex Values. This can be useful when dynamically constructing a Value, or when it is inconvenient to write a custom Serialize implementation or to use #[derive(Serialize)].

Example

use serde_json::builder::ObjectBuilder;

let value = ObjectBuilder::new()
    .insert("name", "point")
    .insert_array("points", |builder| {
        builder
            .push_object(|builder| {
                builder.insert("x", 1).insert("y", 2)
            })
            .push_object(|builder| {
                builder.insert("x", 3).insert("y", 4)
            })
    })
    .unwrap();

Structs

ArrayBuilder

This structure provides a simple interface for constructing a JSON array.

ObjectBuilder

This structure provides a simple interface for constructing a JSON object.