#nlohmann::json doesn't work with std::format

4 messages · Page 1 of 1 (latest)

jolly flare
#

So I have a nlohman::json object and when I try to do this:

std::string connection_config = std::format("host={} port={} dbname={} user={} password='{}'", db_config.at("host"),
                                                db_config.at("port"), db_config.at("dbname")), to_string(db_config.at("user"),
                                                db_config.at("password"));

I get this error:

In template: call to deleted constructor of 'typename format_context::formatter_type<basic_json<std::map, std::vector, string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>>>' (aka 'formatter<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>>, char>')

Do I have to use nlohman's own to_string function or is there another way to handle this?

inland frostBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

inland frostBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.

dire spoke