JSON_EXTRACT_FLOAT

Overview

Extracts a value from a JSON object by path and returns it as FLOAT. Returns NULL if the path does not exist or the value is null.

Syntax

JSON_EXTRACT_FLOAT(<json>, <path>)

Parameters

  • <json>: JSON type, the source data. Strings must first be converted using PARSE_JSON.
  • <path>: STRING type, a JSONPath expression such as '$.field'.

Examples

-- FLOAT has limited precision; the actual output may show precision loss SELECT json_extract_float(PARSE_JSON('{"val":3.14}'), '$.val'); -- 3.140000104904175 -- Path does not exist, returns NULL SELECT json_extract_float(PARSE_JSON('{"val":3.14}'), '$.other'); -- NULL