ts-type-forge
    Preparing search index...

    Type Alias MutableJsonValue

    MutableJsonValue:
        | JsonPrimitive
        | MutableJsonValue[]
        | { [k: string]: MutableJsonValue }

    Represents any valid JSON value that can be modified after creation. This includes primitives, mutable arrays of JSON values, or mutable objects where keys are strings and values are JSON values.

    Use this type when you need to build, modify, or manipulate JSON structures programmatically, such as constructing API payloads or transforming data.

    const apiPayload: MutableJsonValue = {
    user: {
    name: 'John Doe',
    age: 30,
    preferences: ['dark-mode', 'notifications'],
    },
    };

    // Can modify the structure
    const updateAge = (payload: MutableJsonValue): void => {
    if (
    typeof payload !== 'object' ||
    payload === null ||
    Array.isArray(payload)
    ) {
    return;
    }
    const user = payload['user'];
    if (typeof user === 'object' && user !== null && !Array.isArray(user)) {
    user['age'] = 31; // Update age
    }
    };

    updateAge(apiPayload);