Skip to content

Serialization

Export diff results for humans, logs, or downstream tools.

Previous: Patching · Back to: Overview

Playground

Open JSON viewer → — inspect serialized output formats.

Problem → approach

Typical painserialize()
console.log(diffResult) is noisy and not PR-readyserialize(result, "markdown") for changelogs and review comments
APIs need structured payloads; humans need tablesSame diff() output, multiple export formats
Custom formatters duplicated across toolsOne serializer with json, markdown, and table targets

JSON export

ts
import { diff, serialize } from "@jayoncode/object-diff";

const result = diff(before, after);
const json = serialize(result, "json");

Markdown for changelogs

ts
const markdown = serialize(result, "markdown");
// paste into PR body or release notes

Table format

ts
const table = serialize(result, "table");
// compact tabular view for terminals or docs

When to use each format

FormatBest for
jsonAPIs, structured logs
markdownPRs, docs, changelogs
tableCLI output, quick scans

Done with the guides? Browse the API Reference or playground examples.

JOC is a JayOnCode monorepo of @jayoncode/* packages. Docs sync from source via TypeDoc and sync scripts.