yosh-matsuda / cpp-yyjson

Ultra-fast and intuitive C++ JSON reader/writer with yyjson backend
MIT License
63 stars 6 forks source link

Is there any method to check if an object has member? #12

Closed tuongbuimtt closed 8 months ago

tuongbuimtt commented 8 months ago

I've tried, but it doesn't seem be the correct method:

    object obj;
    obj.emplace("ABC", 123);
    if (obj["abc"].is_null())
      cout<< "object has no member named abc" << endl;
     cout << obj.write() << endl;

Of course, the condition is true, and that will print the string, but after call the is_null(), the obj has a member "abc"

object has no member named abc
{"ABC":123,"abc":null}