#include#include int main() { MojObject obj; obj.putBool("isAdult", true); obj.putBool("hasChildren", false); std::cout << obj.toJson().c_str() << std::endl; return 0; }
{"hasChildren":false,"isAdult":true}
#includeThis code creates a MojObject and sets the value of the "isAdult" key to true. It then uses the getBool() function to get the value of the "isAdult" key and verify that it's true. It also tries to get the value of the non-existent "hasChildren" key and verify that the function returns false and the output value is false. The MojObject library is part of the webOS Open Source Edition (OSE) project, which includes a variety of packages for building applications for smart devices.#include int main() { MojObject obj; bool valid = false; // Set the value of the "isAdult" key to true obj.putBool("isAdult", true); // Get the value of the "isAdult" key and check if it's true bool isAdult; valid = obj.getBool("isAdult", isAdult); assert(valid && isAdult); // Get the value of the "hasChildren" key (which does not exist) and check if it's false valid = obj.getBool("hasChildren", isAdult); assert(!valid && !isAdult); return 0; }