This may be premature, postgres 9.4 is still in beta. I experimented with jsonb type. I will not be able to pass the jsonb type to the plv8 function, it enters as a type string. I was wondering if I am doing this wrong?
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$;
then when I run using json:
psql=# select jt('{"member":"test"}'::json);
INFO: type is object
INFO: argument is [object Object]
INFO: member is test
but when i run jsonb:
psql=
INFO: type is string
INFO: argument is {"member": "test"}
INFO: member is undefined
-g
source
share