How to pass a string as a parameter?

Hi,

I intend to move some configuration strings to Thinger in device properties.

When it try to read that property back into a String,

OWM_Id = paramsvalues["OWM_Id"];

I get:

 error: ambiguous overload for 'operator=' (operand types are 'String' and 'protoson::pson')
   17 | }
      |                                 ^
In file included from C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:295,
                 from C:\Users\MiFi\AppData\Local\Temp\arduino\sketches\0FEC703AE722E16582954DDF0A3E1DB7\sketch\ESP_SwissArmyKnife_Rev11_2024.ino.cpp:1:
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:134:17: note: candidate: 'String& String::operator=(const String&)'
  134 |         String &operator =(const String &rhs);
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:135:17: note: candidate: 'String& String::operator=(String&&)'
  135 |         String &operator =(String &&rval) noexcept;
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:136:17: note: candidate: 'String& String::operator=(const char*)'
  136 |         String &operator =(const char *cstr);
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:137:17: note: candidate: 'String& String::operator=(const __FlashStringHelper*)'
  137 |         String &operator =(const __FlashStringHelper *str);
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:138:17: note: candidate: 'String& String::operator=(char)'
  138 |         String &operator =(char c);
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:140:17: note: candidate: 'String& String::operator=(unsigned char)'
  140 |         String &operator =(unsigned char value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:145:17: note: candidate: 'String& String::operator=(int)'
  145 |         String &operator =(int value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:150:17: note: candidate: 'String& String::operator=(unsigned int)'
  150 |         String &operator =(unsigned int value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:155:17: note: candidate: 'String& String::operator=(long int)'
  155 |         String &operator =(long value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:160:17: note: candidate: 'String& String::operator=(long unsigned int)'
  160 |         String &operator =(unsigned long value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:165:17: note: candidate: 'String& String::operator=(long long int)'
  165 |         String &operator =(long long value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:170:17: note: candidate: 'String& String::operator=(long long unsigned int)'
  170 |         String &operator =(unsigned long long value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:175:17: note: candidate: 'String& String::operator=(float)'
  175 |         String &operator =(float value) {
      |                 ^~~~~~~~
C:\Users\MiFi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:180:17: note: candidate: 'String& String::operator=(double)'
  180 |         String &operator =(double value) {
      |                 ^~~~~~~~

exit status 1

Has someone an idea on how to fix that?

Hello @rin67630

I thinks its easier to help you if you extend the sample code to at least a simple but full sketch, in order to see how the variables a declared, as well as the rest of your environment.

To read a property from a device and save its value to a string this should work:

Property named prop

{
    "key": "val"
}
pson data;
thing.get_property("prop", data);
String value = data["key"];
Serial.println(value); // This will print `val`

If the property just contains a string like: “val”:

pson data;
thing.get_property("prop", data);
String value = data;
Serial.println(value); // This will print `val`