M jasm/docs/jasm.md +7 -0
@@ 3154,6 3154,13 @@ This will read at most 4 bytes from offs
<div id="json-data"></div>
## JSON
+Sometimes it's needed to communicate with other tools when building a large project with several compile steps. jAsm supports exporting JSON data using the `[6502]|json_write` function. One dictionary variable (with all contents within) can be exported, as long as it only contains data types matching the JSON specification. That's dictionaries, lists, strings, numbers and booleans. The first argument is the filename, the second the data to export and the third states whether to make the output human readable. A non-human readable export is, a more compact, single line of data.
+
+ [6502]
+ const data = dict("lives" = 3, "rooms" = list(1, 4, 8))
+ const humanreadable = true
+ json_write("some_dir/some_file.json", data, humanreadable)
+
Data in JSON format can also be imported into a variable using the `[6502]|json_read` function. The entire file will be imported as dictionary data.
[6502]
M jasm/website/site/docs/index.html +7 -0
@@ 3281,6 3281,13 @@ end:
<h2>JSON</h2>
+<p>Sometimes it's needed to communicate with other tools when building a large project with several compile steps. jAsm supports exporting JSON data using the <code>json_write</code> function. One dictionary variable (with all contents within) can be exported, as long as it only contains data types matching the JSON specification. That's dictionaries, lists, strings, numbers and booleans. The first argument is the filename, the second the data to export and the third states whether to make the output human readable. A non-human readable export is, a more compact, single line of data.</p>
+
+<pre><code><span class="keyword">const</span> data <span class="operator">=</span> <span class="function">dict</span><span class="special">(</span><span class="literal">"lives"</span> <span class="operator">=</span> <span class="literal">3</span>, <span class="literal">"rooms"</span> <span class="operator">=</span> <span class="function">list</span><span class="special">(</span><span class="literal">1</span>, <span class="literal">4</span>, <span class="literal">8</span><span class="special">)</span><span class="special">)</span>
+<span class="keyword">const</span> humanreadable <span class="operator">=</span> <span class="literal">true</span>
+json_write<span class="special">(</span><span class="literal">"some_dir/some_file.json"</span>, data, humanreadable<span class="special">)</span>
+</code></pre>
+
<p>Data in JSON format can also be imported into a variable using the <code>json_read</code> function. The entire file will be imported as dictionary data.</p>
<pre><code><span class="keyword">const</span> imported_data <span class="operator">=</span> json_read<span class="special">(</span><span class="literal">"some_dir/some_file.json"</span><span class="special">)</span>