1c5f01b2fSopenharmony_ci// __ _____ _____ _____ 2c5f01b2fSopenharmony_ci// __| | __| | | | JSON for Modern C++ (supporting code) 3c5f01b2fSopenharmony_ci// | | |__ | | | | | | version 3.11.2 4c5f01b2fSopenharmony_ci// |_____|_____|_____|_|___| https://github.com/nlohmann/json 5c5f01b2fSopenharmony_ci// 6c5f01b2fSopenharmony_ci// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me> 7c5f01b2fSopenharmony_ci// SPDX-License-Identifier: MIT 8c5f01b2fSopenharmony_ci 9c5f01b2fSopenharmony_ci#include "doctest_compatibility.h" 10c5f01b2fSopenharmony_ci 11c5f01b2fSopenharmony_ci#include <nlohmann/json.hpp> 12c5f01b2fSopenharmony_ci 13c5f01b2fSopenharmony_ciTEST_CASE("use current library with inline namespace") 14c5f01b2fSopenharmony_ci{ 15c5f01b2fSopenharmony_ci SECTION("implicitly") 16c5f01b2fSopenharmony_ci { 17c5f01b2fSopenharmony_ci using nlohmann::json; 18c5f01b2fSopenharmony_ci using nlohmann::ordered_json; 19c5f01b2fSopenharmony_ci 20c5f01b2fSopenharmony_ci json j; 21c5f01b2fSopenharmony_ci // In v3.10.5 mixing json_pointers of different basic_json types 22c5f01b2fSopenharmony_ci // results in implicit string conversion 23c5f01b2fSopenharmony_ci j[ordered_json::json_pointer("/root")] = json::object(); 24c5f01b2fSopenharmony_ci CHECK(j.dump() == "{\"root\":{}}"); 25c5f01b2fSopenharmony_ci } 26c5f01b2fSopenharmony_ci 27c5f01b2fSopenharmony_ci SECTION("explicitly") 28c5f01b2fSopenharmony_ci { 29c5f01b2fSopenharmony_ci using NLOHMANN_JSON_NAMESPACE::json; 30c5f01b2fSopenharmony_ci using NLOHMANN_JSON_NAMESPACE::ordered_json; 31c5f01b2fSopenharmony_ci 32c5f01b2fSopenharmony_ci json j; 33c5f01b2fSopenharmony_ci j[ordered_json::json_pointer("/root")] = json::object(); 34c5f01b2fSopenharmony_ci CHECK(j.dump() == "{\"root\":{}}"); 35c5f01b2fSopenharmony_ci } 36c5f01b2fSopenharmony_ci} 37