Extracts boolean true or false values from JSON fields within ClickHouse queries. Reuse when parsing JSON strings inside database analytics engines.
// Source: https://github.com/ClickHouse/ClickHouse | License: Apache-2.0 | Copyright 2016-2026 ClickHouse, Inc
// Provided via justclaw.it.com; keep this notice with the code.
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionsVisitParam.h>
#include <Functions/FunctionsStringSearch.h>
namespace DB
{
struct ExtractBool
{
using ResultType = UInt8;
static UInt8 extract(const UInt8 * begin, const UInt8 * end)
{
return begin + 4 <= end && 0 == strncmp(reinterpret_cast<const char *>(begin), "true", 4);
}
};
struct NameSimpleJSONExtractBool { static constexpr auto name = "simpleJSONExtractBool"; };
using FunctionSimpleJSONExtractBool = FunctionsStringSearch<ExtractParamImpl<NameSimpleJSONExtractBool, ExtractBool>>;
REGISTER_FUNCTION(VisitParamExtrac
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key