Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Json Schema with Reflector type #509

Closed

Description

@Wittypal

I'm currently using rfl 0.19, but the change notes in the recent versions didnt indicate anything about this behaviour would have changed.
I'm working on a Qt based project trying to reflect QString. So I wrote this based on the example in the docs:

template <>
struct Reflector<QString> {
    using ReflType = std::wstring;

    static QString to(const ReflType& v) noexcept {
        return QString::fromStdWString(v);
    }

    static ReflType from(const QString& v) {
        return { v.toStdWString() };
    }
};

This works fine for parsing/writing, but does not seem to work for the schema generation:

struct RflTest {
    QString test_string;
};
auto a = RflTest{ "AAAAAH" };
auto json_a = rfl::json::write(a);
qDebug() << QString::fromStdString(json_a); // Output: "{\"test_string\":\"AAAAAH\"}"
auto b = rfl::json::read<RflTest>(json_a);
qDebug() << b.value().test_string; // Output: "AAAAAH"
auto schema = rfl::json::to_schema<RflTest>(); // breaks during compilation: "static_assert failed: 'Unsupported type'"
qDebug() << QString::fromStdString(schema);

Is there an additional function that can be overwritten for the Reflector? Or is extending the schema beyond the default types not supported as of now?

Thank you for your work, this library is wildly impressive

Activity

  1. liuzicheng1987 commented on Oct 8, 2025

    @liuzicheng1987
    Collaborator

    All right, I'll take a look.

  2. liuzicheng1987 commented on Oct 19, 2025

    @liuzicheng1987
    Collaborator

    @Wittypal , issue is resolved. Thanks for flagging this!

  3. added a commit that references this issue on Oct 20, 2025
    dfcbff9
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