edgeport - v1.0.6
    Preparing search index...

    Function encodeJson

    • Serializes a value to JSON and encodes it as UTF-8 bytes.

      A one-call replacement for new TextEncoder().encode(JSON.stringify(value)), handy for the byte-oriented publish / send / writeFile APIs. Pair with decodeJson to round-trip.

      Parameters

      • value: unknown

        The value to serialize.

      • Optionalspace: number

        Optional JSON.stringify indentation (number of spaces); omit for compact output.

      Returns Uint8Array

      The UTF-8 bytes of the JSON text.

      1.0.4

      import { encodeJson } from 'edgeport/util';

      encodeJson({ ok: true }); // Uint8Array of '{"ok":true}'