<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=JSON_and_dict_for_parameter_files</id>
	<title>JSON and dict for parameter files - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=JSON_and_dict_for_parameter_files"/>
	<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=JSON_and_dict_for_parameter_files&amp;action=history"/>
	<updated>2026-04-14T13:36:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=JSON_and_dict_for_parameter_files&amp;diff=326&amp;oldid=prev</id>
		<title>Davrot at 16:12, 17 October 2025</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=JSON_and_dict_for_parameter_files&amp;diff=326&amp;oldid=prev"/>
		<updated>2025-10-17T16:12:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:12, 17 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== The goal ==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A combination of JSON (JavaScript Object Notation) file and dictionaries allows to organize parameters in an external file.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A combination of JSON (JavaScript Object Notation) file and dictionaries allows to organize parameters in an external file.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=JSON_and_dict_for_parameter_files&amp;diff=153&amp;oldid=prev</id>
		<title>Davrot: Created page with &quot; == The goal == A combination of JSON (JavaScript Object Notation) file and dictionaries allows to organize parameters in an external file.  Questions to [mailto:davrot@uni-bremen.de David Rotermund]  == [https://docs.python.org/3/library/json.html json – JSON encoder and decoder] ==  === [https://docs.python.org/3/library/json.html#json.dump dump] === &lt;syntaxhighlight lang=&quot;python&quot;&gt;import json  a = dict(one=1, two=2, three=3)  with open(&quot;data_out.json&quot;, &quot;w&quot;) as file:...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=JSON_and_dict_for_parameter_files&amp;diff=153&amp;oldid=prev"/>
		<updated>2025-10-15T13:27:43Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; == The goal == A combination of JSON (JavaScript Object Notation) file and dictionaries allows to organize parameters in an external file.  Questions to [mailto:davrot@uni-bremen.de David Rotermund]  == [https://docs.python.org/3/library/json.html json – JSON encoder and decoder] ==  === [https://docs.python.org/3/library/json.html#json.dump dump] === &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import json  a = dict(one=1, two=2, three=3)  with open(&amp;quot;data_out.json&amp;quot;, &amp;quot;w&amp;quot;) as file:...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== The goal ==&lt;br /&gt;
A combination of JSON (JavaScript Object Notation) file and dictionaries allows to organize parameters in an external file.&lt;br /&gt;
&lt;br /&gt;
Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;br /&gt;
&lt;br /&gt;
== [https://docs.python.org/3/library/json.html json – JSON encoder and decoder] ==&lt;br /&gt;
&lt;br /&gt;
=== [https://docs.python.org/3/library/json.html#json.dump dump] ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
&lt;br /&gt;
a = dict(one=1, two=2, three=3)&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;data_out.json&amp;quot;, &amp;quot;w&amp;quot;) as file:&lt;br /&gt;
    json.dump(a, file)&amp;lt;/syntaxhighlight&amp;gt;Content of data_out.json:&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&amp;quot;one&amp;quot;: 1, &amp;quot;two&amp;quot;: 2, &amp;quot;three&amp;quot;: 3}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [https://docs.python.org/3/library/json.html#json.load load] ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;data_out.json&amp;quot;, &amp;quot;r&amp;quot;) as file:&lt;br /&gt;
    b = json.load(file)&lt;br /&gt;
&lt;br /&gt;
print(b)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;{&amp;#039;one&amp;#039;: 1, &amp;#039;two&amp;#039;: 2, &amp;#039;three&amp;#039;: 3}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://github.com/tikitu/jsmin/ jsmin] and [https://docs.python.org/3/library/json.html#json.loads loads] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;pip install jsmin&amp;lt;/syntaxhighlight&amp;gt;Maybe you want to have comments in your config file.&lt;br /&gt;
&lt;br /&gt;
Content of data_in.json:&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;// This an important comment...&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;one&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;two&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;three&amp;quot;: 3&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;Note for &amp;#039;&amp;#039;&amp;#039;VS Code&amp;#039;&amp;#039;&amp;#039;: You need to change the filetype from &amp;#039;&amp;#039;&amp;#039;JSON&amp;#039;&amp;#039;&amp;#039; to &amp;#039;&amp;#039;&amp;#039;JSON with comments&amp;#039;&amp;#039;&amp;#039;. Lower right corner.&lt;br /&gt;
&lt;br /&gt;
The normal JSON functions fails:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;data_in.json&amp;quot;, &amp;quot;r&amp;quot;) as file:&lt;br /&gt;
    b = json.load(file)&lt;br /&gt;
&lt;br /&gt;
print(b)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;JSONDecodeError: Expecting value: line 1 column 1 (char 0)&amp;lt;/syntaxhighlight&amp;gt;With jsmin:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
from jsmin import jsmin&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;data_in.json&amp;quot;, &amp;quot;r&amp;quot;) as file:&lt;br /&gt;
    minified = jsmin(file.read())&lt;br /&gt;
    &lt;br /&gt;
b = json.loads(minified)&lt;br /&gt;
&lt;br /&gt;
print(b)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;{&amp;#039;one&amp;#039;: 1, &amp;#039;two&amp;#039;: 2, &amp;#039;three&amp;#039;: 3}&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
</feed>