Skip to content

Omit property names #130

Open
Open
@hpx7

Description

@hpx7

I'm using msgpack to transmit objects with a fixed schema, so it feels wasteful to encode the property names with each payload. Is there some way to provide some schema information to the encoder/decoder during initialization so that property names can be excluded from the serialization output?

Proposal of what this api could look potentially like:

import { ValueOnlyEncoder, ValueOnlyDecoder } from "@msgpack/msgpack";

const schema = ... // some representation of your object schema, contains the property names
const encoder = new ValueOnlyEncoder(schema);
const decoder = new ValueOnlyDecoder(schema);

const data = { foo: [1, 2, 3], bar: "baz" };

const encoded = encoder.encode(data); // fails if data doesn't conform to schema
const decoded = decoder.decode(encoded);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions