File tree 3 files changed +20
-1
lines changed
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
#include < Arduino_JSON.h>
11
+ #include < assert.h>
11
12
12
13
const char input[] = " {\" result\" :true,\" count\" :42,\" foo\" :\" bar\" }" ;
13
14
@@ -78,7 +79,19 @@ void demoCreation() {
78
79
79
80
myObject[" hello" ] = " world" ;
80
81
myObject[" true" ] = true ;
81
- myObject[" x" ] = 42 ;
82
+
83
+ myObject[" x1" ] = (int ) 42 ;
84
+ myObject[" x2" ] = (long ) 42 ;
85
+ myObject[" x3" ] = (unsigned long ) 42 ;
86
+
87
+ int x1 = myObject[" x1" ];
88
+ assert (x1 == 42 );
89
+
90
+ long x2 = myObject[" x2" ];
91
+ assert (x2 == 42 );
92
+
93
+ unsigned long x3 = myObject[" x3" ];
94
+ assert (x3 == 42 );
82
95
83
96
Serial.print (" myObject.keys() = " );
84
97
Serial.println (myObject.keys ());
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ JSONVar::operator long() const
142
142
return cJSON_IsNumber (_json) ? _json->valueint : 0 ;
143
143
}
144
144
145
+ JSONVar::operator unsigned long () const
146
+ {
147
+ return cJSON_IsNumber (_json) ? _json->valueint : 0 ;
148
+ }
149
+
145
150
JSONVar::operator double () const
146
151
{
147
152
return cJSON_IsNumber (_json) ? _json->valuedouble : NAN;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class JSONVar : public Printable {
49
49
operator bool () const ;
50
50
operator int () const ;
51
51
operator long () const ;
52
+ operator unsigned long () const ;
52
53
operator double () const ;
53
54
operator const char *() const ;
54
55
You can’t perform that action at this time.
0 commit comments