123

Revision:
2:e39bfa3e917d
Parent:
1:effaca3e3f84
Child:
3:f2ffae08b963
--- a/MbedJSONValue.h	Thu Sep 22 10:40:57 2011 +0000
+++ b/MbedJSONValue.h	Thu Sep 22 10:54:29 2011 +0000
@@ -24,7 +24,7 @@
 * THE SOFTWARE.
 *
 * @section DESCRIPTION
-*    Types Abstraction. JSON serializer and parser. (inspired by picojson). Is used by MbedJSONRpc.
+*    Types Abstraction. Minimalist JSON serializer and parser (inspired by picojson). Is used by MbedJSONRpc.
 *
 */
 
@@ -47,17 +47,24 @@
  *         -a boolean identified by "my_boolean"
  *    - serialization in JSON format of this object
  * @code
- *     MbedJSONValue demo;
- *     std::string s;
+ * #include "mbed.h"
+ * #include "MbedJSONValue.h"
+ * #include <string>
+ *
+ * int main() {          
+ *
+ *   MbedJSONValue demo;
+ *   std::string s;
  *
- *     //fill the object
- *     demo["my_array"][0] = "demo_string";
- *     demo["my_array"][1] = 10;
- *     demo["my_boolean"] = true;
+ *   //fill the object
+ *   demo["my_array"][0] = "demo_string";
+ *   demo["my_array"][1] = 10;
+ *   demo["my_boolean"] = false;
  *
- *     //serialize it into a JSON string
- *     s = demo.serialize();
- *
+ *   //serialize it into a JSON string
+ *   s = demo.serialize();
+ *   printf("json: %s\r\n", s.c_str());
+ * }
  *  
  * @endcode
  *
@@ -65,22 +72,30 @@
  *     - creation of an MbedJSONValue from a JSON string
  *     - extraction of different values from this existing MbedJSONValue
  * @code
- *
- *     MbedJSONValue demo;
+ * #include "mbed.h"
+ * #include "MbedJSONValue.h"
+ * #include <string>
  *
- *     const  char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
+ * int main() {     
+ *    MbedJSONValue demo;
  *
- *     //parse the previous string and fill the object demo
- *     parse(demo, json);
+ *   const  char * 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>();
- *
+ *   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");
+ * }
  * @endcode
  */
 class MbedJSONValue {
@@ -111,6 +126,7 @@
     * @param value the object created will be initialized with this boolean
     */
     MbedJSONValue(bool value) : _type(TypeBoolean), index_array(0), index_token(0) {
+        printf("bool created\r\n");
         _value.asBool = value;
     }
     
@@ -179,6 +195,14 @@
     MbedJSONValue& operator=(int const& rhs) { return operator=(MbedJSONValue(rhs));  }
     
     /**
+    * = Operator overloading for an MbedJSONValue from a boolean
+    *
+    * @param rhs boolean
+    * @return a reference on the MbedJSONValue affected
+    */
+    MbedJSONValue& operator=(bool const& rhs) { return operator=(MbedJSONValue(rhs));  }
+    
+    /**
     * = Operator overloading for an MbedJSONValue from a double
     *
     * @param rhs double