JsonFormat is the contract for serializing messages to and from JSON. Implementations may be specific to a proto syntax, and can be reflection based, or delegate to speed optimized generated code.

interface JsonFormat {
    debug(json): string;
    makeReadOptions(options?): Readonly<JsonReadOptions>;
    makeWriteOptions(options?): Readonly<JsonWriteStringOptions>;
    readMessage<T>(type, jsonValue, options, message?): T;
    readScalar(type, json, longType?): any;
    writeMessage(message, options): JsonValue;
    writeScalar(type, value, emitDefaultValues): undefined | JsonValue;
}

Methods

  • Returns a short string representation of a JSON value, suitable for error messages.

    Parameters

    Returns string

  • Parse a message from JSON.

    Type Parameters

    Parameters

    Returns T

  • Parse a single scalar value from JSON.

    This method may throw an error, but it may have a blank error message. Callers are expected to provide context.

    Parameters

    Returns any

  • Serialize a message to JSON.

    Parameters

    Returns JsonValue

  • Serialize a single scalar value to JSON.

    Parameters

    • type: ScalarType
    • value: any
    • emitDefaultValues: boolean

    Returns undefined | JsonValue

Generated using TypeDoc