<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonas on Medium]]></title>
        <description><![CDATA[Stories by Jonas on Medium]]></description>
        <link>https://medium.com/@jonas_arkulpa?source=rss-78cfd7898f75------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Jonas on Medium</title>
            <link>https://medium.com/@jonas_arkulpa?source=rss-78cfd7898f75------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 06:24:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonas_arkulpa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pretty Json Stringify ]]></title>
            <link>https://medium.com/arkulpa/pretty-json-stringify-952157440b86?source=rss-78cfd7898f75------2</link>
            <guid isPermaLink="false">https://medium.com/p/952157440b86</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Jonas]]></dc:creator>
            <pubDate>Tue, 24 Apr 2018 04:48:13 GMT</pubDate>
            <atom:updated>2018-04-24T05:04:03.576Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>TIL — 26.03.2018</h4><p>Due to the fact that I learn small but exciting things almost every day and tend to forget too much about this stuff too fast I decided to write them down as TIL articles and share them with you.</p><p>Without further ado lets discover an amazingly simple thing a colleague showed me today. Thank you very much <a href="https://medium.com/u/cbd0963876af">Torsten Hain</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//twitter.com/peter_shirley/status/985566165920448512&amp;image=https%3A//i.embed.ly/1/image%3Furl%3Dhttps%253A%252F%252Fpbs.twimg.com%252Fmedia%252FDa1vM4DU8AA8qGm.jpg%253Alarge%26key%3Da19fcc184b9711e1b4764040d3dc5c07" width="500" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6819cec2fd43da66cf5b9455c4b017a/href">https://medium.com/media/e6819cec2fd43da66cf5b9455c4b017a/href</a></iframe><p>Unfortunately this image mirrors my usual development pretty accurate (and I’m sure I’m not the only one) but if we do non optimal things why not at least do them pretty? 💅</p><p>Disclaimer: The pretty emoji is obviously stolen from <a href="https://www.styled-components.com/">styled-components</a>.<br>Thanks <a href="https://medium.com/u/908fb8fea30c">Max Stoiber</a>.</p><p>I have a lot of use cases where I log stuff. For example I inspect the state of an object or a value, use the output as mock in my code, send it to colleagues or use it in documentation.</p><p>Almost always I need an illustrative representation which is easy to observe.<br>My usual workflow till today was to log the stringified version, copy it in some kind of formatter and use the prettified result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zd7KyK8YTTQCdIAWmlW9A.png" /><figcaption>Example of simple usage of JSON.stringify</figcaption></figure><p>Apart from the obvious drawback of repeating the same work over &amp; over again this also has other cons you have to keep in mind.<br>If you use an online tool (like <a href="https://jsonformatter.curiousconcept.com/">this json formatter</a>) you may want to omit any secrets you don’t want to send to an external service. These are sometimes hard to find in the unformatted json even if you haven’t forgotten to think about removing them in the first place.<br>As alternatives you can use a local formatter, the auto format feature of your favorite IDE (<a href="https://medium.com/arkulpa/what-is-the-best-editor-for-my-needs-faadc0946ba5">which is a hard choice on its own</a>) or use Prettier to format your code IDE agnostic.</p><p><a href="https://github.com/prettier/prettier">GitHub - prettier/prettier: Prettier is an opinionated code formatter.</a></p><p>In browsers where you have an interactive console (in contrast to for example node logs) the need is sometimes not that urgent because you can expand an object layer by layer.<br>But even there I often stringify a logged object via the Chrome feature »Store as global variable« and <em>JSON.stringify(temp1)</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4d4aRGfAZcDB7YtEv3DkuQ.png" /><figcaption>Example of using »Store as global variable«</figcaption></figure><p>Now lets reveal the amazingly simple secret I learned today. 🔑<br>The stringify function does take more than one argument. With the third argument it is possible to specify the spacing which results in a formatted json output. 💅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9TU179_zF6c8yKoxhorig.png" /><figcaption>Example of an amazingly simple change which results in formatted JSON.stringify output</figcaption></figure><p>It is also possible to specify a string as spacing if you need a more advanced usage. For completeness the second argument lets you pass a replacer function which allows to omit or replace properties in the result.<br>To learn more details you can always reference to the documentation.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify">JSON.stringify() - JavaScript | MDN</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*7F4_E6cymazEZsd4ir4czQ.jpeg" /><figcaption>Jonas Hackenberg — <a href="/service/mailto:jonas@arkulpa.at">jonas@arkulpa.at</a> — <a href="https://www.arkulpa.at/">www.arkulpa.at</a></figcaption></figure><p>*</p><p>Thanks for reading my first TIL article. If you enjoyed it don’t hesitate to clap &amp; comment your thoughts. I hope to continue this series and present a lot of other interesting learnings. 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=952157440b86" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arkulpa/pretty-json-stringify-952157440b86">Pretty Json Stringify 💅</a> was originally published in <a href="https://medium.com/arkulpa">arkulpa</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>