Load the data from a File (TEXT)
ASTER::ACTION::JSON::Load from a JSON Formatted File.
Load the data from a JSON File.
The data is loaded from the JSON file at the specified file path, and after the data parsing is executed, the JSON data is loaded into memory if there are no errors in the content.
--- title: Load from a JSON Formatted File --- flowchart LR A[Set a File Path] --> B{The File Exist?} B --> |Yes| C((Check JSON Format)) B --> |No| D[Fail to Load] C --> |Correct| E((Load the Data to Memory)) C --> |Incorrect!| F[Error: Invalid JSON] D --> G[Cancelled] F --> G[Cancelled] E --> H(Loaded)
Parameter
The location of the application executable file is referred to as the “current directory.”
Here is a sample for loading the file 00.json
located in the ./json/sandbox
directory under the current directory.
"./json/sandbox/00.json"
current application folder/
└── json/
└── sandobox/
└── 00.json 👻🙂
-
If the file does not exist at the specified path, an error message will be displayed, and the process will terminate immediately.
-
If the parsing of the JSON formatted data fails, an error message will be displayed, and the loading process will terminate immediately.
Note.1
Loss of edited data
If a JSON load command is issued while JSON data is currently being edited in memory, the memory pointer information will first be erased. Therefore, even if the load fails, the currently edited data will be completely lost.
Note.2
Error (Exception Occurrence)
If invalid JSON data is loaded, an exception will occur.
Parse errors due to data format issues can be reliably avoided by using a text editor with error-checking functionality.
- Recommended editors include Visual Studio Code.
Note.3
About
BOM
(Byte Order Mark) withUTF-8
.
It is a variant of the UTF-8 format mainly used in Windows OS environments. The use of UTF-8 with BOM is not allowed according to RFC 8259 (page 9).
However, currently, loading UTF-8 with BOM
in ASTER does not produce errors due to the Byte Order Mark.
Please do not use UTF-8 with BOM as it is not officially supported.