Browse Source

Merge pull request #20 from mariolukas/master

Optimized JSON for file-browser.
master
biologist79 5 years ago
committed by GitHub
parent
commit
4d52dfce05
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 12
      src/main.cpp

1
.gitignore

@ -1,4 +1,5 @@
.pio .pio
venv/
.vscode/.browse.c_cpp.db* .vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json .vscode/c_cpp_properties.json
.vscode/launch.json .vscode/launch.json

12
src/main.cpp

@ -488,15 +488,15 @@ void appendNodeToJSONFile(fs::FS &fs, const char * path, const char *filename, c
//TODO: write a minified json, without all those whitespaces //TODO: write a minified json, without all those whitespaces
// it is just easier to debug when json is in a nice format // it is just easier to debug when json is in a nice format
// anyway ugly but works and is stable // anyway ugly but works and is stable
file.print(F(( " {\n \"id\" : \"")));
file.print(F("{\"id\":\""));
file.print(filename); file.print(filename);
file.print(F("\",\n \"parent\" : \""));
file.print(F("\",\"parent\":\""));
file.print(parent); file.print(parent);
file.print(F("\",\n \"type\": \""));
file.print(F("\",\"type\":\""));
file.print(type); file.print(type);
file.print(F("\",\n \"text\" : \""));
file.print(F("\",\"text\":\""));
file.print(filename); file.print(filename);
file.print(F("\"\n }"));
file.print(F("\"}"));
// i/o is timing critical keep all stuff running // i/o is timing critical keep all stuff running
esp_task_wdt_reset(); esp_task_wdt_reset();
yield(); yield();
@ -598,7 +598,7 @@ void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint
* is done. * is done.
*/ */
void createJSONFileList() { void createJSONFileList() {
createFile(SD, DIRECTORY_INDEX_FILE, "[\n");
createFile(SD, DIRECTORY_INDEX_FILE, "[");
parseSDFileList(SD, "/", NULL, FS_DEPTH); parseSDFileList(SD, "/", NULL, FS_DEPTH);
appendToFile(SD, DIRECTORY_INDEX_FILE, "]"); appendToFile(SD, DIRECTORY_INDEX_FILE, "]");
isFirstJSONtNode = true; isFirstJSONtNode = true;

Loading…
Cancel
Save