Nlohmann :: json 3.11.3 - JSON_POINTEC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Nlohmann :: json 3.11.3 - JSON_POINTE

Сообщение Anonymous »

I'm developing a simple program in c++20 that reads a json file using the nlohmann::json 3.11.3 library and Qt 6.8+...
My problem is using json_pointers correctly, let me explain better by starting to show you a JSon structure:
{
"bar": {
"Qt": "6.8",
"json": "3.11.3",
"array_json": ["/bar/Qt", "/bar/json"]
},
"foo": null
}
< /code>
Хорошо, теперь мой пример кода в этом: < /p>
using json = nlohmann::ordered_json;

// create a json object
json data = R"(
{
"bar": {
"Qt": "6.8",
"json": "3.11.3",
"array_json": ["/bar/Qt", "/bar/json"]
},
"foo": null
}
)"_json;

// get the second element of the "array_json"
QString s_pointer = QString::fromStdString(data["bar"]["array_json"][1].get();

//expected value of pointer = "/bar/json"
qInfo() "/bar/json"

// create a json_pointer
json::json_pointer j_pointer(data["bar"]["array_json"][1].get());

//expected value of json pointer = "/bar/json"
qInfo() "/bar/json"

// get the value of /bar/json using json pointer
QString value = QString::fromStdString(data[j_pointer].get()); // warning here, but its working fine...

qInfo()
Здесь сведения о предупреждении я получил ... < /p>

main.cpp:92:53: 'operator ==' Умерен: с 3.11.2; Используйте Operator == (json_pointer, json_pointer) < /p>
< /blockquote>

p>json.hpp:3981:10: в экземпляре спецификации исключений для 'operator () std :: basic_string

json.hpp:3993:31: во время вычета аргумента шаблона для частичной специализации шаблона класса 'is_comparable

Подробнее здесь: https://stackoverflow.com/questions/795 ... ated-since
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»