Getting error "call of overloaded 'println(protoson::pson&)' is ambiguous"

Hello! I'm currently messing around with an Adafruit Feather Huzzah ESP8266 and I'm trying to learn how to use webhooks. I've been using IFTTT with Thinger.io to make this work. Currently, the code works for doing the thing when IFTTT sends the webhook POST but the issue I'm running into is displaying the JSON info. It's giving me an error:

call of overloaded 'println(protoson::pson&)' is ambiguous

I've spent hours now trying to figure this out but I'm just getting lost and the only piece of info I found was This... I'm not sure if it can even help me with this but I just can't seem to figure this out. IFTTT sends this

{"content": "{{Title}}"}

but I can't figure out how to get it to display on my OLED screen.
here's my code:

#include <ThingerESP8266.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define USERNAME "***"
#define DEVICE_ID "***"
#define DEVICE_CREDENTIAL "***"
#define SSID "***"
#define SSID_PASSWORD "***"

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  display.clearDisplay();
  display.println("Waiting...");
  display.display();

  thing.add_wifi(SSID, SSID_PASSWORD);

  thing["new_follower"] << [](pson & in) {
    display.clearDisplay();
    display.println("Post Title:");
    display.println(in["content"]);
    display.display();
  };
}

void loop() {
  thing.handle();
}

This right here is what's causing me the issues:

display.println(in["content"]);

the code works fine and prints "Post Title:" When I remove the part that's supposed to print the actual info in so this is my only problem with my code.
Any help is greatly appreciated and thank you for your time!

I have no clue about IFTTT, but the error message means that there are more than one function 'println' and their arguments differ. (Overloaded means loaded over).

Typecasting the argument may fix this, then the compiler can figure out which function you mean to use.

(I could be wrong, but this is how I understand overloading).

(Reference)

The full compiler messages will tell you WHY the call is ambiguous. There will be two (or more) functions named .println() that can take an argument converted from type "protoson::pson&". Figure out which one you want to call and CAST the argument to that exact type. Since it is now an exact match for one of the choices it is no longer ambiguous.

Post the full error messages (copy and paste from the box below the sketch) if you want more help.

IcyBlade:
This right here is what's causing me the issues:

display.println(in["content"]);

What is that line intended to do? To me it appears you have an array, "in", and you want to print the element of the array whose position is given by the physical memory address where a string literal is stored.

david_2018:
What is that line intended to do? To me it appears you have an array, "in", and you want to print the element of the array whose position is given by the physical memory address where a string literal is stored.

OP is using class from ThingerESP8266 library that overloads operator[].

Trouble is, println() doesn't know what to do with the result returned by that overload.

johnwasser:
The full compiler messages will tell you WHY the call is ambiguous. There will be two (or more) functions named .println() that can take an argument converted from type "protoson::pson&". Figure out which one you want to call and CAST the argument to that exact type. Since it is now an exact match for one of the choices it is no longer ambiguous.

Post the full error messages (copy and paste from the box below the sketch) if you want more help.

ahhh sorry about that. Didn't even realize I didn't post the full error message. Here it is:

In file included from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/thinger.h:27:0,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h:29,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:27,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerESP8266.h:28,
                 from C:\Users\freed\AppData\Local\Temp\arduino_modified_sketch_333524\ESP8266.ino:1:
C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/pson.h:45:15: warning: unused parameter 'sz' [-Wunused-parameter]
 inline void * operator new(size_t sz, void * here, void* dummy) { return here; }
               ^
C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/pson.h:45:15: warning: unused parameter 'dummy' [-Wunused-parameter]
C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/pson.h:718:22: warning: unused parameter 'buffer' [-Wunused-parameter]
         virtual bool read(void* buffer, size_t size){
                      ^
In file included from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/thinger.h:27:0,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h:29,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:27,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerESP8266.h:28,
                 from C:\Users\freed\AppData\Local\Temp\arduino_modified_sketch_333524\ESP8266.ino:1:
C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/thinger/pson.h:918:22: warning: unused parameter 'buffer' [-Wunused-parameter]
         virtual bool write(const void* buffer, size_t size){
                      ^
In file included from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:27:0,
                 from C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerESP8266.h:28,
                 from C:\Users\freed\AppData\Local\Temp\arduino_modified_sketch_333524\ESP8266.ino:1:
C:\Users\freed\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h:300:18: warning: unused parameter 'state' [-Wunused-parameter]
     virtual void thinger_state_listener(THINGER_STATE state){
                  ^
C:\Users\freed\AppData\Local\Temp\arduino_modified_sketch_333524\ESP8266.ino: In lambda function:
ESP8266:33:36: error: call of overloaded 'println(protoson::pson&)' is ambiguous
       display.println(in["content"]);
                                    ^
C:\Users\freed\AppData\Local\Temp\arduino_modified_sketch_333524\ESP8266.ino:33:36: note: candidates are:
In file included from C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Stream.h:26:0,
                 from C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h:32,
                 from C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:245,
                 from sketch\ESP8266.ino.cpp:1:
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:92:16: note: size_t Print::println(const __FlashStringHelper*)
         size_t println(const __FlashStringHelper *);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:93:16: note: size_t Print::println(const String&)
         size_t println(const String &s);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:94:16: note: size_t Print::println(const char*)
         size_t println(const char[]);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:95:16: note: size_t Print::println(char)
         size_t println(char);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:96:16: note: size_t Print::println(unsigned char, int)
         size_t println(unsigned char, int = DEC);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:97:16: note: size_t Print::println(int, int)
         size_t println(int, int = DEC);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:98:16: note: size_t Print::println(unsigned int, int)
         size_t println(unsigned int, int = DEC);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:99:16: note: size_t Print::println(long int, int)
         size_t println(long, int = DEC);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:100:16: note: size_t Print::println(long unsigned int, int)
         size_t println(unsigned long, int = DEC);
                ^
C:\Users\freed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h:101:16: note: size_t Print::println(double, int)
         size_t println(double, int = 2);
                ^
exit status 1
call of overloaded 'println(protoson::pson&)' is ambiguous

david_2018:
What is that line intended to do? To me it appears you have an array, "in", and you want to print the element of the array whose position is given by the physical memory address where a string literal is stored.

that line is supposed to take the application/json data sent by IFTTT which is

{"content": "{{Title}}"}

and display it on an OLED screen

IcyBlade:
that line is supposed to take the application/json data sent by IFTTT which is

{"content": "{{Title}}"}

and display it on an OLED screen

What data type is returned by in["content"] ??

gfvalvo:
What data type is returned by in["content"] ??

I'm not 100% sure since I'm just learning all this and don't understand it all yet but I think it is JSON. Sorry if that's not the right type of data type you were asking about as this is all pretty confusing to me right now.

I don't the Thinger library installed, so I can only guess try:

display.println((const char *) in["content"]);

gfvalvo:
What data type is returned by in["content"] ??

From the error message, it's returning a "protoson::pson &". Apparently, there are multiple ways to convert that type into something that can be printed and the compiler can't decide which to use.

#8

Here is the source for protoson::pson:

Good Luck. I looked through and couldn't find a method that would return a printable representation of the object. That object has a type field so you COULD use the type to figure out which function to call to get the value.

johnwasser:
I looked through and couldn't find a method that would return a printable representation of the object.

The pson class overloads 'operator const char *':

       operator const char *() {
            switch(field_type_){
                case string_field:
                    return (const char*) value_;
                case empty:
                    field_type_ = empty_string;
                default:
                    return "";
            }
        }

OP didn't provide sufficient info to know for sure, but it appears that the desired data could be a cstring. If so, the cast I suggested in Reply #9 might work.

gfvalvo:
I don't the Thinger library installed, so I can only guess try:

display.println((const char *) in["content"]);

This might also work:

display.println(in["content"].operator const char *());

okay, so I've done some more experimenting and trying to figure this out, both bits of code work to display it now and everything compiles nicely. Now I've gotten to a point where I'm not sure anyone here can help with because it has to do with Reddit and IFTTT. I'm going to list what I've found, my code, and then my new problem.

Here's a quick rundown of how everything should work:
I save a post on Reddit
IFTTT then sends a POST using the webhook thing, I'm guessing it sends all the data I have laid out in the body of the application/json
My ESP8266 then receives that and takes the Title data
It displays that Title data onto the OLED

I'm using saving a post on Reddit as my trigger as it's easy to do and I can trigger it anytime I need to test it. Plus I want this working with Reddit anyways so learning with this just makes it easy.

So both

display.println((const char *) in["content"]);

and

display.println(in["content"].operator const char *());

work and display what is supposed to be displayed on the OLED screen.

When I use my Thinger.io dashboard to view my ESP8266 I can see the API and I'm not sure if you would call it a function or maybe event? but anyway I can test send data to it, so I'm guessing it sends it as IFTTT should. I can put in any text and it has "String" by the input box so I'm guessing the data sent is supposed to be a string? I'm not exactly sure how that works so i may be completely wrong. When I put any text in there and send it, everything works as it should and it displays the text I inputted on the OLED. Here's a screenshot of what I'm talking about for the input box:
Imgur: The magic of the Internet

I've also edited the IFTTT application/json body to this:

{
 "in": 
 [ 
   { 
     "title": "<<<{{Title}}>>>", 
     "url": "<<<{{PostURL}}>>>", 
     "description": "<<<{{Content}}>>>",
     "thumbnail": { 
       "url": "<<<{{ImageURL}}>>>"
     }, 
     "footer": { 
       "icon_url": "https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png", 
       "text": "/u/<<<{{Author}}>>> | <<<{{PostedAt}}>>>" 
     } 
   } 
 ] 
}

I'm not 100% if that is the correct stuff to put in there but everywhere I've seen stuff about using Reddit with IFTTT, they use this as the body for the webhook.

I've changed some stuff around in my code, like the names and the Thing name, here's my current code that compiles and works when I manually send info through Thinger.io:

#define _DEBUG_
#include <SPI.h>
#include <Wire.h>
#include <ThingerESP8266.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

#define USERNAME "***"
#define DEVICE_ID "***"
#define DEVICE_CREDENTIAL "***"
#define SSID "***"
#define SSID_PASSWORD "***"

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  Serial.begin(115200);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println("Started"); //this is just used as feedback for me to know it started
  display.display();

  thing.add_wifi(SSID, SSID_PASSWORD);
  
  thing["new_save"] << [](pson& in){
      display.clearDisplay();
      display.setCursor(0, 0);
      display.println("Post Title:");
      display.println(in["title"].operator const char *());
      display.display();
  };
}

void loop() {
  thing.handle();
}

So, great, it works! I'm very grateful and excited I was able to get help with the compiling issue so thank you very much!

Now onto my new problem. When I save a post and the IFTTT applet gets triggered, everything works except actually displaying the title text. It runs the Thing as the OLED Switches from "Started" to "Post Title:" but there's no other text that gets displayed... IFTTT says the applet ran successfully but I'm guessing I've done something wrong with the IFTTT application/json body and that's why it does not display the title? So my problem I'm pretty sure has now moved onto IFTTT, as the code works and I can manually trigger it with Thinger.io.