Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2?

推荐答案

Looking at the source for PostgreSQL 9.2.1:

Source: postgresql-9.2.1\src\backend\utils\adt\json.c:
/*
 * Input.
 */
Datum
json_in(PG_FUNCTION_ARGS)
{
    char       *text = PG_GETARG_CSTRING(0);

    json_validate_cstring(text);

    /* Internal representation is the same as text, for now */
    PG_RETURN_TEXT_P(cstring_to_text(text));
}

Update for PostgreSQL 9.3.5:

The code has changed in the json_in function, but the json internal representation is still text:

Source: postgresql-9.3.5\src\backend\utils\adt\json.c:
/*
 * Input.
 */
Datum
json_in(PG_FUNCTION_ARGS)
{
    char       *json = PG_GETARG_CSTRING(0);
    text       *result = cstring_to_text(json);
    JsonLexContext *lex;

    /* validate it */
    lex = makeJsonLexContext(result, false);
    pg_parse_json(lex, &nullSemAction);

    /* Internal representation is the same as text, for now */
    PG_RETURN_TEXT_P(result);
}

So it appears that, for now at least, json is the same as a text datatype but with JSON validation. The text datatype's maximum size is 1GB.

Json相关问答推荐

JOLT拉平数组

输入请求中不存在null的条件抖动

Google Page to JSON应用程序脚本出现CORS错误

在scala中将字符串列转换为 struct 的JSON映射

如何使用PowerShell从ExchangeOnline命令执行中获得JSON输出

对一些JSON模式验证的混淆

Jolt Spec 跳过数组中的第一个元素

Moshi:序列化 List 时出现问题

Ansible - 将文件内容添加到字典中

VBA-JSON 嵌套集合解析为 Excel

jq可以在两个JSON对象列表中依次添加对象吗?

Jolt - 在同一级别添加时组合值的问题

将 JSON 数据导入 Google 表格

如何获取json格式的KendoGrid显示数据?

使用 c# 通用地展平 Json

将json字符反序列化为枚举

Android JSON 库的性能和可用性比较

Swift :将 struct 转换为 JSON?

通过 JSON 发送 HTML 代码

Gson 将一组数据对象转换为 json - Android