Making Pretty-Printed JSON Readable Again in Python
A new Python module called jsonfold has been developed to improve the readability of JSON data. This module acts as a post-processing filter on top of existing JSON serializers, allowing for a balance between compact and fully expanded formats. It offers customization options for formatting, making it suitable for handling large documents efficiently.
- ▪Jsonfold provides a way to format JSON data that is more readable than traditional compact or pretty-printed outputs.
- ▪The module operates as a streaming wrapper, ensuring fixed memory usage and linear processing time for large documents.
- ▪Customization options include maximum line width, folding depth, and packing aggressiveness.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 1298982) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Yair Lenga Posted on May 24 • Originally published at Medium Making Pretty-Printed JSON Readable Again in Python #programming #python #backend #opensource Most JSON serializers give you only two choices: compact machine output: {"a":{"b":{"c":"abc"}},"x":{"y":{"z":"xyz"}}} Enter fullscreen mode Exit fullscreen mode or fully expanded “pretty-print”: { "a": { "b": { "c": "abc" } }, "x": { "y": { "z": "xyz" } } } Enter fullscreen mode Exit fullscreen mode I wanted something in between:…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).