This may be premature, postgres 9.4 is still in beta. I've been experimenting with the jsonb type. I am not having any luck passing a jsonb type to a plv8 function, it comes in as type string. I was wondering if I was doing it 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 with jsonb:
psql=# select jt('{"member":"test"}'::jsonb);
INFO: type is string
INFO: argument is {"member": "test"}
INFO: member is undefined
-g