Closed
Description
The following code tests the presence of a particular attribute using a json pointer, in two different ways. It prints '1' for the first (which is correct), but '0' for the second line.
#include "json.hpp"
#include <fstream>
#include <iostream>
int main(int, char **)
{
nlohmann::json j = {
{"pi", 3.141},
{"happy", true},
{"name", "Niels"},
{"nothing", nullptr},
{"answer", {
{"everything", 42}
}}
};
nlohmann::json::json_pointer ptr("/name");
std::cout << j.contains( nlohmann::json::json_pointer("/name") ) << std::endl;
std::cout << j.contains( ptr ) << std::endl;
}
Any ideas? I would have guessed these are equivalent, but obviously they are not. Tested with g++ 7.4 and clang++ 8.0 using json.hpp 3.7.0.