Skip to content

jsondiff

Compute shallow set/unset differences between JSONB objects

jsondiff · Compute shallow set/unset differences between JSONB objects

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102129jsondiffjsondiff1.0FUNCC

PostgreSQL · 16

Usage

Sources:

jsondiff is the small C component of a course-project audit application. It exposes one shallow JSONB difference function; the audit tables, triggers and snapshot reconstruction belong to separate application scripts.

Core Workflow

CREATE EXTENSION jsondiff;
SELECT public.compute_json_diff('{"a":1,"b":2}'::jsonb, '{"a":3,"c":4}'::jsonb);

Operational Boundaries

public.compute_json_diff(before_json, after_json) returns an object containing set for added/changed keys and unset for removed keys. Nested values are replaced as whole values rather than recursively diffed. Use object-shaped input and validate edge cases before applying diffs to application records.

The versioned SQL fixes the function in public despite a relocatable control flag; do not rely on schema relocation to move this function. Installation requires a superuser and the compiled C library. No preload is specified. Upstream’s build example uses PostgreSQL 16; no broader support matrix or license is declared.

Table reader