这可能还为时过早,postgres 9.4还在测试阶段。我一直在试验jsonb型。我没有运气将一个jsonb类型传递给一个plv8函数,它是作为类型字符串出现的。我在想我是不是做错了?
create or replace function jt ( o json ) returns integer language plv8 immutable
AS $function$
plv8.elog(INFO, 'type is ', typeof o);
plv8.elog(INFO, 'argument is ', o);
plv8.elog(INFO, 'member is ', o['member']);
$function$;
create or replace function jt ( o jsonb ) returns integer language plv8 immutable
AS $function$
plv8.elog(INFO, 'type is ', typeof o);
plv8.elog(INFO, 'argument is ', o);
plv8.elog(INFO, 'member is ', o['member']);
$function$;然后,当我使用json运行时:
psql=# select jt('{"member":"test"}'::json);
INFO: type is object
INFO: argument is [object Object]
INFO: member is test但是,当我和jsonb一起跑的时候:
psql=# select jt('{"member":"test"}'::jsonb);
INFO: type is string
INFO: argument is {"member": "test"}
INFO: member is undefined-g
发布于 2014-08-22 01:24:51
PL/V8需要添加对JSONB的支持,然后才能按照您的预期工作。
同时,您仍然可以传递普通的json;只需将jsonb转换为json即可。
2015年以来的新闻
plv8项目在2014年后改名为该项目的发起人和主要贡献者JerrySievert的这一评论,在2017年:
JSONB和JSON的速度差异是众所周知的,并且得到了解决, JSONB现在在C++中直接转换为v8对象,运行速度比JSON转换快
上一次修订历史显示了一些关于JSONb启动日期的线索:
建议使用plv8版本2.3.10或更高版本的JSONB .不过,对于较早版本的plv8、贾里,几乎一切都会很好:
自2015年4月22日以来,JSONB的支持一直是积极和完整的。
https://stackoverflow.com/questions/25433445
复制相似问题