How can a numeric score be extracted from a model's JSON response?
With one path, json_extract returns an SQL number for a JSON number and text for a JSON string.
SQLite example and interpretation
Score 7 and the string “7” look similar but have different extracted types. Check the producer's contract before numeric sorting.
SELECT typeof(json_extract('{"s":7}','$.s')),typeof(json_extract('{"s":"7"}','$.s'));Result [["integer", "text"]]
中文
怎样从模型响应中取出可比较的数值分数?
单路径 json_extract 提取 JSON 数值时返回 SQL 数值,提取 JSON 字符串时返回文本。
SQLite 示例与适用条件
分数 7 与字符串“7”看似相同,提取后的类型不同。先检查生产者的数据契约再进行数值排序。
SELECT typeof(json_extract('{"s":7}','$.s')),typeof(json_extract('{"s":"7"}','$.s'));结果 [["integer", "text"]]