folly::dynamic::asBool

Type conversion.

Synopsis

Declared in <folly/json/dynamic.h>

bool
asBool() const;

Description

Extract a value while trying to convert to the specified type. Throws exceptions if we cannot convert from the real type to the requested type.

C++ will implicitly convert between bools, ints, and doubles; these conversion functions also try to convert between arithmetic types and strings. E.g. dynamic d = "12"; d.asDouble() -> 12.0.

Note: you can only use this to access integral types or strings, since arrays and objects are generally best dealt with as a dynamic.

Return Value

The value converted to the requested type. methodset Conversion