JSON file in mbed.
Dependencies: MbedJSONValue SDFileSystem mbed
Fork of City_Game_JSON by
Diff: main.cpp
- Revision:
- 3:0ace19f0cc2b
- Parent:
- 2:e6a095fc2274
- Child:
- 5:eedf89829452
--- a/main.cpp Wed Mar 29 07:01:05 2017 +0000 +++ b/main.cpp Wed Mar 29 07:18:26 2017 +0000 @@ -1,26 +1,23 @@ #include "mbed.h" #include "MbedJSONValue.h" -//#include "SDFileSystem.h" +#include "SDFileSystem.h" #include "mission.h" #include <iostream> #include <vector> using namespace VivesCityGame; -//SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // mosi, miso, sclk, cs +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // mosi, miso, sclk, cs -/* #define charlimit 100 char words[charlimit]; int n = 0, c; -*/ int main() { MbedJSONValue demo; - /* FILE * fp1 - = fopen("/sd/text.json", "r"); + = fopen("/sd/test.json", "r"); if(fp1 == NULL) { error("Could not open file for read!\r\n"); @@ -28,7 +25,7 @@ printf("Reading from SD card...\r\n"); - while((c = fgetc(fp1)) && c! = EOF) + while((c = fgetc(fp1)) && c!=EOF) { words[n] = c; n++; @@ -37,9 +34,9 @@ printf("Read from SD card: %s\r\n", words); fclose(fp1); - */ - const char * json = "{\"gameMode\":\"LocationGame\",\"gameModeId\":1,\"version\":\"1.235\",\"creationDate\":\"11-02-2017\",\"missions\":[{\"type\":\"gotoLocation\",\"id\":1,\"message\":\"Go to the big roundabout in Oostende.\",\"deadline\":true,\"deadlineTime\":30,\"latitude\":51.21543,\"longitude\":2.928656,\"radius\":200},{\"type\":\"puzzle\",\"id\":2,\"message\":\"Find the key A\",\"hint\":\"Look in a tree\",\"deadline\":false}]}"; + //const char * json = "{\"gameMode\":\"LocationGame\",\"gameModeId\":1,\"version\":\"1.235\",\"creationDate\":\"11-02-2017\",\"missions\":[{\"type\":\"gotoLocation\",\"id\":1,\"message\":\"Go to the big roundabout in Oostende.\",\"deadline\":true,\"deadlineTime\":30,\"latitude\":51.21543,\"longitude\":2.928656,\"radius\":200},{\"type\":\"puzzle\",\"id\":2,\"message\":\"Find the key A\",\"hint\":\"Look in a tree\",\"deadline\":false}]}"; + const char * json = words; //const char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}"; // parse the previous string and fill the object demo