0

I have list of messages and I need to convert to Json them. And now I use this solution;

Bu I see to<> function. This function generic and I can use vector (iterator) But how can use custom Adapter?

My solution:

vector<MyMessageClass> messages = TODO()
Json::Value json;

ranges::for_each(messages, [&json](const MyMessageClass &msg) {
    json.append(msg.to_json());
});

I want

vector<MyMessageClass> messages = TODO()
Json::Value json = messages | ranges::to<Json::Value>();

0 Answers0