File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,14 @@ void demoCreation() {
7878
7979 myObject[" hello" ] = " world" ;
8080 myObject[" true" ] = true ;
81- myObject[" x" ] = 42 ;
81+
82+ myObject[" x1" ] = (int ) 42 ;
83+ myObject[" x2" ] = (long ) 42 ;
84+ myObject[" x3" ] = (unsigned long ) 42 ;
85+
86+ int x1 = myObject[" x1" ];
87+ long x2 = myObject[" x2" ];
88+ unsigned long x3 = myObject[" x3" ];
8289
8390 Serial.print (" myObject.keys() = " );
8491 Serial.println (myObject.keys ());
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ JSONVar::operator long() const
142142 return cJSON_IsNumber (_json) ? _json->valueint : 0 ;
143143}
144144
145+ JSONVar::operator unsigned long () const
146+ {
147+ return cJSON_IsNumber (_json) ? _json->valueint : 0 ;
148+ }
149+
145150JSONVar::operator double () const
146151{
147152 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 {
4949 operator bool () const ;
5050 operator int () const ;
5151 operator long () const ;
52+ operator unsigned long () const ;
5253 operator double () const ;
5354 operator const char *() const ;
5455
You can’t perform that action at this time.
0 commit comments