jsonb_plperlu

jsonb_plperlu

plperlu : transform between jsonb and plperlu

Overview

ID Extension Package Version Category License Language
3272
jsonb_plperlu
plperlu
1.0
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Requires
plperlu
See Also
jsquery
jsonb_plperl
jsonb_plpython3u
pg_jsonschema
plperl
plpgsql
Siblings
plperlu
bool_plperlu
hstore_plperlu

Packages

PG18 PG17 PG16 PG15 PG14
1.0
1.0
1.0
1.0
1.0

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION jsonb_plperlu CASCADE; -- requires plperlu

Usage

jsonb_plperlu: Transform between jsonb and PL/Perl untrusted

Provides a transform for the jsonb type for PL/Perl Untrusted. When loaded, jsonb values are automatically converted to Perl data structures (hashes, arrays, scalars) and vice versa.

CREATE EXTENSION jsonb_plperlu;

CREATE FUNCTION process_json_u(val jsonb) RETURNS text
LANGUAGE plperlu TRANSFORM FOR TYPE jsonb AS $$
  use JSON;
  # val is already a Perl data structure, re-encode with sorting
  return encode_json($val);
$$;

CREATE FUNCTION build_jsonb_u(name text, age integer) RETURNS jsonb
LANGUAGE plperlu TRANSFORM FOR TYPE jsonb AS $$
  my ($name, $age) = @_;
  return { name => $name, age => $age };
$$;

SELECT process_json_u('{"b": 2, "a": 1}'::jsonb);
SELECT build_jsonb_u('Alice', 30);
Last updated on