Help with Adafruit IO JSON error: "no method named 'Get' in class java.lang.Boolean"

Hey everyone,

I’m having a bit of trouble with my project. I’m trying to display data from an Adafruit IO group on my labels, but they aren’t updating.

I’m getting this specific error:

invoke: no method named 'Get' in class java.lang.Boolean

I understand this probably means my JSON Text Decode block is failing and returning false instead of a dictionary, but I’m not sure how to fix it.

Here are my code blocks. First, I call the API when the screen initializes:

And here is how I handle the response in the Web1.GotText event:



Could anyone see what might be wrong with my logic? How can I correctly check for an error before trying to parse the JSON data?

Thanks in advance for your help!

Are you using any extension? Which ones?
Taifun

If you’re asking about extensions in my Chrome browser, I only use Adobe PDF and Google Docs Offline. As for extensions in the Kodular project itself, I’m not using any at all.

The error means your JSON decode is failing and returning false. Try showing the raw responseContent first to confirm the API output. Then check if result ≠ false before using .Get. Also note Adafruit IO often returns a dictionary with a feeds list — so you need to get feeds → select list item → last_value.

That error is not something with your blocks
Are you using the latest version of the companion app? Does it work after building the project?

Taifun

It is not the solution but if you want to optimize a little bit you can do this,

agree with securebugs

I think you were right that the problem is related to the JSON content. Here’s what I found:

  1. When I display the raw responseContent directly to a label, it works perfectly and shows the full JSON string.
  2. When I used the if/else block you suggested (the one in the image), it also worked—the code inside the then block ran. However, I still briefly saw the invoke...Boolean error notification pop up.

But here is the strangest part: after my Companion connection was lost and I reconnected it, the boolean error has completely disappeared. Now, the code works correctly without any error notifications.

My guess is that the server was sending inconsistent data at first. I will continue to test it step-by-step and will add the extra check inside the for each loop to make the code more robust.

Great, thanks! I’ll test this out now and will report back with the results.

The result of this if statement always will be true, because rootDict is a string and never can be a boolean value
As already mentioned earlier

There you go

Taifun

Hi Taifun, at first I thought you were right about it being a Companion bug. However, when I installed and ran the APK, this specific screen (Status_Panel) still won’t show the data.

IT WORKS!!! A HUGE thank you to everyone in this thread, I LOVE YOU GUYS! FINALLY, I CAN SLEEP PEACEFULLY​:heart:
This is my last program:

But my journey isn’t over just yet. Now I have a new question about controlling the layout with radio buttons, checkboxes, and images :slight_smile:

How can I set up my radio buttons so that when I click RadioButtonA, some components become hidden (to create a “simple” view), and when I click RadioButtonB, those components become visible again (for a “detailed” view)?

1 Like

Very well!
:partying_face::partying_face::partying_face:

Make sure to always check that the question you’re going to ask hasn’t already been solved in another post.