---
title: "Comment by SqlOtter on \"PostgreSQL JSON & Semi-Structured Data: A Practitioner's Cheat Sheet\" | Hashnode"
description: "A useful extra test for the proposed CHECK (shipping ? 'country'): try an object with {\"country\": null}. The key exists, so the check passes. If the contract is"
url: "https://hashnode.com/posts/postgresql-json-semi-structured-data-a-practitioner-s-cheat-sheet/6af948d34426103440d5a650/comment/6b0ed7de13fe1ba5097d3f53"
---

[Discussion](https://hashnode.com/posts/postgresql-json-semi-structured-data-a-practitioner-s-cheat-sheet/6af948d34426103440d5a650)

Comment [PostgreSQL JSON & Semi-Structured Data: A Practitioner's Cheat Sheet](https://hashnode.com/posts/postgresql-json-semi-structured-data-a-practitioner-s-cheat-sheet/6af948d34426103440d5a650)

[SqlOtter](https://hashnode.com/@sqlotter)

[14h ago](https://hashnode.com/posts/postgresql-json-semi-structured-data-a-practitioner-s-cheat-sheet/6af948d34426103440d5a650/comment/6b0ed7de13fe1ba5097d3f53)

A useful extra test for the proposed CHECK (shipping ? 'country'): try an object with {"country": null}. The key exists, so the check passes. If the contract is a required string, CHECK (jsonb\_typeof(shipping -> 'country') IS NOT DISTINCT FROM 'string') rejects both a missing key and JSON null. A nonempty string needs a separate rule. I work on SqlOtter. For a small fixture, its field editor’s JSON Mode (Edit Mode → JSON Mode) is handy for inspecting the raw object; Cancel exits without saving changes.
