Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungBreeze TTS 2 vs ElevenLabs: Open Source TTS Verdict(23.09.2026 um 05:44 Uhr)
Sichere ProgrammierungAgentic AI vs Generative AI: The 2026 Verdict(23.09.2026 um 05:44 Uhr)
Sichere ProgrammierungI made my agent prove every quote against the source document(23.09.2026 um 05:45 Uhr)
Sichere Programmierung8mb.video Alternative: Skip the Line, Skip the Upsell(23.09.2026 um 05:47 Uhr)
Sichere ProgrammierungBuilding a GTA 6 JSON API for entities and current status(23.09.2026 um 05:52 Uhr)
Sichere ProgrammierungEvery filter needs a documented exception(23.09.2026 um 06:01 Uhr)
Sichere ProgrammierungBreeze TTS 2 vs ElevenLabs: Open Source TTS Verdict(23.09.2026 um 05:44 Uhr)
Sichere ProgrammierungAgentic AI vs Generative AI: The 2026 Verdict(23.09.2026 um 05:44 Uhr)
Sichere ProgrammierungI made my agent prove every quote against the source document(23.09.2026 um 05:45 Uhr)
Sichere Programmierung8mb.video Alternative: Skip the Line, Skip the Upsell(23.09.2026 um 05:47 Uhr)
Sichere ProgrammierungBuilding a GTA 6 JSON API for entities and current status(23.09.2026 um 05:52 Uhr)
Sichere ProgrammierungEvery filter needs a documented exception(23.09.2026 um 06:01 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Making Pretty-Printed JSON Readable Again in JavaScript

Most JSON serializers give you only two choices: compact machine output: {"a":{"b":{"c":"abc"}},"x":{"y":{"z":"xyz"}}} or fully expanded “pretty-print”: { "a": { "b": { "c": "abc" } }, "x": { "y": { …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Most JSON serializers give you only two choices:




  • compact machine output:




{"a":{"b":{"c":"abc"}},"x":{"y":{"z":"xyz"}}}







  • or fully expanded “pretty-print”:




{
"a": {
"b": {
"c": "abc"
}
},
"x": {
"y": {
"z": "xyz"
}
}
}






I wanted something in between: the first is hard for humans to scan, and the second becomes extremely verbose on real-world nested data.






The Idea



I wrote a small JavaScript module called jsonfold. Instead of replacing JavaScript's JSON serializer, it works as a lightweight post-processing filter on top of JSON.stringify() output.



The formatter selectively:




  • folds small containers back onto one line,

  • packs short scalar sequences,

  • keeps large or complex structures expanded.



Example output:




{
"a": { "b": { "c": "abc" } },
"x": { "y": { "z": "xyz" } }
}









Why This Approach?



I did not want to rebuild a serializer. JavaScript already provides an excellent serializer in JSON.stringify(), including support for custom transformations through the replacer callback and configurable indentation.



The formatter can be used either as a streaming filter or through convenience wrappers that behave similarly to JSON.stringify().




import { stringify } from "@jsonfold/core";

const data = {
a: { b: { c: "abc" } },
x: { y: { z: "xyz" } }
};

console.log(stringify(data));






That means you can continue using the standard JavaScript serialization pipeline while producing more compact and readable output.






Customization



The formatter allows controlling:




  • maximum line width,

  • folding depth,

  • packing aggressiveness,

  • array/object limits.



So you can choose between conservative formatting and more aggressive compaction.






Full Article:



Medium (no paywall): A Streaming JSON Formatter for JavaScript that Works with JSON.stringify






Minimal Usage



Install:




npm install @jsonfold/core









import { dump } from "@jsonfold/core";

const data = {
meta: { version: 1, ok: true },
ids: [1, 2, 3, 4, 5],
items: [
{ id: 1, name: "alpha" },
{ id: 2, name: "beta" }
]
};

// compact can be: default, low, med, high, max
dump(data, process.stdout, {
compact: "default"
});









GitHub Project



Web site: https://jsonfold.dev/



Repository: https://github.com/yairlenga/jsonfold



JavaScript implementation is under the javascript directory.



Future articles will cover other implementations: Python, Java, Perl, C, ... please watch the GitHub project, or follow the articles on Medium.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Making Pretty-Printed JSON Readable Again in JavaScript

Thematisch verwandte Begriffe: Making, PrettyPrinted, JSON, Readable · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-17636 | IBM Financial Transaction Manager (FTM) for RedHat OpenShift could allow…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick