JSValue val = 10.5; if (val.isDouble()) { double d = val.asDouble(); // use double value }
JSValue val = { "name": "John", "age": 42 }; if (val.isDouble()) { // won't enter this block as the value is not a double }In this example, we create a JSValue object with a JSON object containing a name and an age. The isDouble() function is called to check if the value is a floating point number. As it is not, the if statement block will not be executed. Package/Library: JsCPPJsonCpp Library, which provides C++ JSON parser and generator.