Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MbedJSONValue mbed
Diff: main.cpp
- Revision:
- 3:632a7590a341
- Parent:
- 2:c887a1b1b762
- Child:
- 4:7d1077d2a30b
--- a/main.cpp Mon Jan 15 12:45:43 2018 +0000
+++ b/main.cpp Mon Jan 15 12:46:23 2018 +0000
@@ -5,6 +5,8 @@
/*
Construct packet from uart and parse with json format
json:<PACKET>\r\n
+ test with
+ json:{"my_array": ["demo_string", 10], "my_boolean": true}
*/
/*
@@ -222,23 +224,23 @@
pc.printf("%s", json);
#endif
- MbedJSONValue demo;
+ MbedJSONValue demo;
- //const char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
- // json:{"my_array": ["demo_string", 10], "my_boolean": true}
- //parse the previous string and fill the object demo
- parse(demo, json);
+ //const char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
+ // json:{"my_array": ["demo_string", 10], "my_boolean": true}
+ //parse the previous string and fill the object demo
+ parse(demo, json);
- std::string my_str;
- int my_int;
- bool my_bool;
+ std::string my_str;
+ int my_int;
+ bool my_bool;
- my_str = demo["my_array"][0].get<std::string>();
- my_int = demo["my_array"][1].get<int>();
- my_bool = demo["my_boolean"].get<bool>();
-
- printf("my_str: %s\r\n", my_str.c_str());
- printf("my_int: %d\r\n", my_int);
- printf("my_bool: %s\r\n", my_bool ? "true" : "false");
-
+ my_str = demo["my_array"][0].get<std::string>();
+ my_int = demo["my_array"][1].get<int>();
+ my_bool = demo["my_boolean"].get<bool>();
+
+ printf("my_str: %s\r\n", my_str.c_str());
+ printf("my_int: %d\r\n", my_int);
+ printf("my_bool: %s\r\n", my_bool ? "true" : "false");
+
}
\ No newline at end of file