One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
Macaulay2
/
JSON
/
html
/
View File Name :
_from__J__S__O__N.html
<!DOCTYPE html> <html lang="en"> <head> <title>fromJSON -- decode JSON data into Macaulay2 things</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <link type="text/css" rel="stylesheet" href="../../../../Macaulay2/Style/doc.css"> <link rel="stylesheet" href="../../../../Macaulay2/Style/katex/katex.min.css"> <script defer="defer" src="../../../../Macaulay2/Style/katex/katex.min.js"></script> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/auto-render.min.js"></script> <script> var macros = { "\\break": "\\\\", "\\ZZ": "\\mathbb{Z}", "\\NN": "\\mathbb{N}", "\\QQ": "\\mathbb{Q}", "\\RR": "\\mathbb{R}", "\\CC": "\\mathbb{C}", "\\PP": "\\mathbb{P}" }, delimiters = [ { left: "$$", right: "$$", display: true}, { left: "\\[", right: "\\]", display: true}, { left: "$", right: "$", display: false}, { left: "\\(", right: "\\)", display: false} ], ignoredTags = [ "kbd", "var", "samp", "script", "noscript", "style", "textarea", "pre", "code", "option" ]; document.addEventListener("DOMContentLoaded", function() { renderMathInElement(document.body, { delimiters: delimiters, macros: macros, ignoredTags: ignoredTags, trust: true }); }); </script> <style>.katex { font-size: 1em; }</style> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/copy-tex.min.js"></script> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/render-a11y-string.min.js"></script> <script src="../../../../Macaulay2/Style/prism.js"></script> <script>var current_version = '1.25.06';</script> <script src="../../../../Macaulay2/Style/version-select.js"></script> <link type="image/x-icon" rel="icon" href="../../../../Macaulay2/Style/icon.gif"> </head> <body> <div id="buttons"> <div> <a href="https://macaulay2.com/">Macaulay2</a> <span id="version-select-container"></span> » <a title="Macaulay2 documentation" href="../../Macaulay2Doc/html/index.html">Documentation </a> <br><a href="../../Macaulay2Doc/html/_packages_spprovided_spwith_sp__Macaulay2.html">Packages</a> » <span><a title="JSON encoding and decoding" href="index.html">JSON</a> :: <a title="decode JSON data into Macaulay2 things" href="_from__J__S__O__N.html">fromJSON</a></span> </div> <div class="right"> <form method="get" action="https://www.google.com/search"> <input placeholder="Search" type="text" name="q" value=""> <input type="hidden" name="q" value="site:macaulay2.com/doc"> </form> <a href="___Indent__Level.html">next</a> | <a href="index.html">previous</a> | <a href="___Indent__Level.html">forward</a> | <a href="index.html">backward</a> | up | <a href="master.html">index</a> | <a href="toc.html">toc</a> </div> </div> <hr> <div> <h1>fromJSON -- decode JSON data into Macaulay2 things</h1> <ul> <li> <dl class="element"> <dt>Usage: </dt> <dd><code class="language-macaulay2">fromJSON s</code></dd> </dl> </li> <li>Inputs: <ul> <li><span><span class="tt">s</span>, <span>a <a title="the class of all strings" href="../../Macaulay2Doc/html/___String.html">string</a></span> or <span>a <a title="the class of all files" href="../../Macaulay2Doc/html/___File.html">file</a></span>, </span></li> </ul> </li> <li>Outputs: <ul> <li><span><span>a <a title="the class of all things" href="../../Macaulay2Doc/html/___Thing.html">thing</a></span>, the Macaulay2 equivalent of the given data; </span></li> </ul> </li> </ul> <div> <h2>Description</h2> <div> <p>The JSON data provided in the given string or file is parsed using the <a title="a framework for building parsers" href="../../Parsing/html/index.html">Parsing</a> package with the context-free grammar specified by <a href="https://datatracker.ietf.org/doc/html/rfc8259">RFC 8259</a>. The type of the return value will vary depending on the data.</p> <p>Numbers will result in <span class="tt">ZZ</span> or <span class="tt">RR</span> objects, as appropriate.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i1 : fromJSON "2" o1 = 2</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i2 : fromJSON "2.71828" o2 = 2.71828 o2 : RR (of precision 53)</code></pre> </td> </tr> </table> <div> <p>Strings will result in strings.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i3 : fromJSON "\"Hello, world!\"" o3 = Hello, world!</code></pre> </td> </tr> </table> <div> <p>JSON's <span class="tt">true</span> and <span class="tt">false</span> will result in the corresponding Macaulay2 booleans.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i4 : fromJSON "true" o4 = true</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i5 : fromJSON "false" o5 = false</code></pre> </td> </tr> </table> <div> <p>Due to the implementation of the <span class="tt">Parsing</span> package, <a title="the unique member of the empty class" href="../../Macaulay2Doc/html/_null.html">null</a> cannot be a return value, and so the symbol <a title="a symbol a parser may return to indicate acceptance of the empty string of tokens" href="../../Parsing/html/_nil.html">nil</a> is returned when JSON's <span class="tt">null</span> is given.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i6 : fromJSON "null" o6 = nil o6 : Symbol</code></pre> </td> </tr> </table> <div> <p>Objects will result in hash tables.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i7 : fromJSON "{\"foo\": 1, \"bar\": 2}" o7 = HashTable{"bar" => 2} "foo" => 1 o7 : HashTable</code></pre> </td> </tr> </table> <div> <p>Arrays will result in lists.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i8 : fromJSON "[1, 2, 3]" o8 = {1, 2, 3} o8 : List</code></pre> </td> </tr> </table> <div> <p>The input may also be a file containing JSON data.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i9 : jsonFile = temporaryFileName() | ".json" o9 = /tmp/M2-323843-0/0.json</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i10 : jsonFile << "[1, 2, 3]" << endl << close o10 = /tmp/M2-323843-0/0.json o10 : File</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i11 : fromJSON openIn jsonFile o11 = {1, 2, 3} o11 : List</code></pre> </td> </tr> </table> </div> <div> <div class="waystouse"> <h2>Ways to use <span class="tt">fromJSON</span>:</h2> <ul> <li><kbd>fromJSON(File)</kbd></li> <li><kbd>fromJSON(String)</kbd></li> </ul> </div> <div class="waystouse"> <h2>For the programmer</h2> <p>The object <a title="decode JSON data into Macaulay2 things" href="_from__J__S__O__N.html">fromJSON</a> is <span>a <a title="a type of method function" href="../../Macaulay2Doc/html/___Method__Function.html">method function</a></span>.</p> </div> <hr> <div class="waystouse"> <p>The source of this document is in <span class="tt">JSON.m2:349:0</span>.</p> </div> </div> </div> </body> </html>