惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
B
Blog
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
大猫的无限游戏
大猫的无限游戏
U
Unit 42
J
Java Code Geeks
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
git diff on JSON is mostly noise. So I built a structural...
benjamin · 2026-06-17 · via DEV Community
Cover image for git diff on JSON is mostly noise. So I built a structural diff.

benjamin

You change one value in a JSON config, run git diff, and get a wall of red and green — because a formatter reflowed the file, or the serializer reordered the keys, or the indentation shifted by two spaces. The one thing you actually changed is buried in there somewhere. Good luck finding it in review.

The problem is that git diff and diff work on lines. JSON isn't lines — it's a tree. So I built jdelta: it compares the data, ignores key order and whitespace entirely, and tells you exactly which values changed, addressed by path. Zero dependencies, no network.

What it looks like

$ jdelta config.before.json config.after.json

Added (1)
  + features.darkMode  true

Changed (2)
  ~ auth.required      true → false
  ~ server.port        8080 → 3000

+1  -0  ~2

auth.required flipped to false and you can see it instantly — no scrolling past 200 lines of reindented braces.

Why not git diff / diff?

Because they diff text. Run a formatter, sort your keys, change two spaces of indent, and a line differ lights up the whole file while reporting zero semantic change. jdelta parses both sides and walks the trees:

  • Object keys show as user.profile.age; array elements as items[2].price. Odd keys fall back to quoted brackets (["order-id"]).
  • A key on only one side is added / removed; a key on both with a different value is changed. A type change (numberstring, objectarray) is one changed entry tagged with the kinds — not a confusing add + remove.
  • Reordered keys and whitespace produce nothing, because they aren't data changes.

Great for reviewing config changes, API-response snapshots, tsconfig/settings.json, lockfile-adjacent files, and test fixtures.

In scripts and CI

jdelta a.json b.json --json        # machine-readable: {added, removed, changed, summary}
jdelta a.json b.json --quiet       # just the +a -r ~c line
jdelta a.json b.json --exit-code   # exit 1 if they differ — gate a pipeline on it

Install

npx jdelta a.json b.json      # Node build (npm)
pip install jdelta            # Python build — same behavior

Two builds, Node and Python, that walk the tree identically, so it fits whatever your repo already runs.

A couple of honest design notes

  • Zero dependencies, both builds. stdlib only on each side — a diff tool that pulled in a dependency tree of its own would be missing the point.
  • Arrays are compared by index. Simple and predictable; inserting at the front of a big array reads as "everything shifted" rather than guessing at moves. I'd rather be honest than clever here.
  • Integer precision. JavaScript parses every JSON number as a 64-bit float, so the Node build can't reliably diff integers past ±2^53 (snowflake IDs, int64 DB keys). The Python build keeps integer precision exactly — reach for it when your data has big integers. (It's documented in the README rather than hidden.)

Links


What do you reach for today when you need to diff two JSON files and git diff just won't do? And does anyone gate CI on structural config diffs — or is that still a manual eyeball step?