logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class JsonObjectWriter

    Builds a single flat JSON object literal one property at a time, handling comma placement, string escaping, and null values. Used to compose small fixed wire DTOs.

    Inheritance
    object
    JsonObjectWriter
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.StructuredPersistence.Infrastructure.Json
    Assembly: Serenity.StructuredPersistence.Json.dll
    Syntax
    public sealed class JsonObjectWriter

    Constructors

    JsonObjectWriter()

    Declaration
    public JsonObjectWriter()

    Methods

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()

    WriteDouble(string, double)

    Writes a double property as a JSON number using round-trip ("G17") formatting, so the exact double value survives the encode/decode round trip.

    Declaration
    public JsonObjectWriter WriteDouble(string name, double value)
    Parameters
    Type Name Description
    string name
    double value
    Returns
    Type Description
    JsonObjectWriter

    WriteInt(string, int)

    Writes an integer property as a JSON number.

    Declaration
    public JsonObjectWriter WriteInt(string name, int value)
    Parameters
    Type Name Description
    string name
    int value
    Returns
    Type Description
    JsonObjectWriter

    WriteQuotedLong(string, long)

    Writes a 64-bit integer property as a QUOTED JSON string (not a JSON number). JSON numbers are commonly parsed into IEEE-754 doubles, which only exactly represent integers up to 2^53 — far below the range of real 64-bit values. Quoting the digits keeps the exact value intact across the wire for any conformant reader.

    Declaration
    public JsonObjectWriter WriteQuotedLong(string name, long value)
    Parameters
    Type Name Description
    string name
    long value
    Returns
    Type Description
    JsonObjectWriter

    WriteString(string, string)

    Writes a string property, or the JSON null literal when value is null.

    Declaration
    public JsonObjectWriter WriteString(string name, string value)
    Parameters
    Type Name Description
    string name
    string value
    Returns
    Type Description
    JsonObjectWriter
    In this article
    © 2026 Serenity. All Rights Reserved