|
1 | | -# -*- coding: utf-8 -*- |
2 | | - |
3 | 1 | """ |
4 | | -JSON |
| 2 | +JSON File Format |
5 | 3 |
|
6 | | -Basic implementation for an JSON importer. |
| 4 | +JSON importer (via Python's "json" module). |
7 | 5 | """ |
8 | 6 |
|
9 | | -from mathics.core.builtin import Builtin |
10 | | -from mathics.core.expression import Evaluation |
11 | | -from mathics.eval.fileformats.jsonformat import eval_JSONImport |
| 7 | +from mathics.core.builtin import Builtin, String |
| 8 | +from mathics.core.evaluation import Evaluation |
| 9 | +from mathics.eval.fileformats.json import eval_JSONImport |
12 | 10 |
|
13 | 11 |
|
14 | | -class JSONImport(Builtin): |
| 12 | +class ImportJSON(Builtin): |
15 | 13 | """ |
16 | | - ## <url>:native internal:</url> |
| 14 | + <url>:WMA link:https://reference.wolfram.com/language/ref/format/JSON.html</url> |
17 | 15 |
|
18 | 16 | <dl> |
19 | | - <dt>'JSON`Import`JSONImport["file"]' |
20 | | - <dd>parses "string" as a JSON file, and returns the data as a nested \ |
21 | | - list of rules. |
| 17 | + <dt>'JSON`ImportJSON[path]' |
| 18 | + <dd>Read $path$ as JSON and convert that to its corresponding Mathics3 equivalent. |
22 | 19 | </dl> |
23 | 20 |
|
24 | 21 | """ |
25 | 22 |
|
26 | | - summary_text = "import elements from json" |
27 | | - context = "JSON`Import`" |
| 23 | + context = "JSON`" |
28 | 24 | messages = {"dec": "Decoding Error at `1`"} |
| 25 | + summary_text = "import JSON file" |
29 | 26 |
|
30 | | - def eval(self, filename, evaluation: Evaluation): |
31 | | - """%(name)s[filename_String]""" |
32 | | - return eval_JSONImport(filename.value, evaluation) |
| 27 | + def eval(self, path: String, evaluation: Evaluation): |
| 28 | + "JSON`ImportJSON[path_String]" |
| 29 | + return eval_JSONImport(path, evaluation) |
0 commit comments