Skip to content

Binary data in rfl::Generic #781

Open

Description

@jinchengJL

Currently, Generic's variant list is:

  using VariantType = std::variant<bool, int64_t, double, std::string, Object,
                                   Array, std::nullopt_t>;

This list has no alternative for binary data, so it cannot cleanly represent base64-encoded JSON, or MessagePack BIN values. Using std::string for arbitrary bytes loses the distinction between text and binary and isn’t portable across formats that expect UTF-8 strings.

Would you consider adding some kind of support for this?

FWIW I have considered adding a new alternative here, but it has its issues: it's kind of a breaking change and all backends must be updated, and also when decoding JSON, there isn't enough information to deduce whether a string is a byte string or regular one. So if supporting this isn't desirable I understand.

Thanks!

Activity

  1. liuzicheng1987 commented on Nov 15, 2026

    @liuzicheng1987
    Collaborator

    @jinchengJL I think adding bytestrings here should be possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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