Who could advise me on how apply this code-logic in the BLOCKS section of Thunkable

When Button.Click
set global inputWord to TextInput.Text // Get user input

if inputWord in glossary
    set Label for translation to glossary[inputWord].translation // Show translation
    set Label for example to glossary[inputWord].example // Show example
    set Image.Source to glossary[inputWord].image // Show image
else
    set Label for translation to "Word not found." // Message if word not found

If you’re new to Thunkable, follow the official tutorials from Thunkable Academy listed on this page: Getting Started Guide | Thunkable Docs to learn how to use it. What you’ve listed is fairly simple but you’ll need to start connecting blocks. If you get stuck, post a screenshot of your blocks or a link to your project and someone can probably help you.

Thank you. I understand the idea of blocks and how to use the blocks, but I cannot find the necessary combination of blocks for this very simple code.

And this is also my JSON code:

{
    "Side diffuser": {
        "translation": "Боковой диффузор",
        "example": "Utilization of side diffuser can be beneficial for downforce / Возможно использование бокового диффузора для увеличения прижимной силы",
        "image": "Side diffuser.png",
        "link": "-"
    },
    "Sidepods": {
        "translation": "Боковые понтоны",
        "example": "Sidepods are used to provide enough air for the cooling system through the radiator, while normalizing the turbulent flow coming from the front wheels and slow down the air in order to be more time for the convection to take place within the radiator’s fins / Боковые понтоны используются для подачи достаточного количества воздуха в систему охлаждения через радиатор, одновременно нормализуя турбулентный поток, исходящий от передних колес, и замедляя движение воздуха, чтобы было больше времени для конвекции внутри ребер радиатора",
        "image": "Sidepods.png",
        "link": "-"
    }
}

I have a tutorial video that explains how to parse JSON from an API: API JSON Tutorial (Video)

Thunkable – this is a link to my project. I really got stuck.
Very simple logic:
When Button.Click
set word to TextInput.Text
if word in glossary
set Label for translation to glossary[word].translation
set Label for example to glossary[word].example
set Image source to glossary[word].image
set Label for link to glossary[word].link
else
set Label for translation to “Слово не найдено.”

It may be simple logic but it requires a lot of steps. It’s going to take you some time to code that. For someone who has a lot of experience with this, it would still take 30-60 minutes.

Here’s one example of how to parse JSON to get a specific property value:

Project link: Thunkable

Note that I am not using the Web API block here… I am just manually setting the JSON response from what you posted above.

·····················································································································
Need help? How to Ask Great Questions :sparkles: Debugging A Project :sparkles: API JSON Tutorial

Thank you.

What is wrong with this code?
How to write the content of the “Type here” field into the variable?

You are complicating things by trying to get a property value from the JSON and trying to get a value from the Text Input at the same time. Were you able to follow my video tutorial? I would start there and make sure you can get a single value from your API JSON response.

Thank you, Tatiang.
I cannot watch your video as YouTube doesn’t work in my country (even with the use of VPN).
I understand that it is too complicated when I am trying to get a value from the two sources at the same time, but I don’t see another way of solving this problem (I simply do not see the appropriate blocks).
Common sense tell me that you should first get a value from the “Type Here” field and, then, check this value against the JSON. It’s a pity that I can’t find similar projects to see the code structure therein.

What is wrong with this code?

Why this one is also incorrect?

No luck with the third one as well.

You cannot use labels and variables in this way by using a period (.) to separate the component and it’s property. The only way to get a label’s text is to use a dark green block. The only way to get a text input’s text is to use a light green block. So “inputWord.translation” has no meaning in Thunkable. It doesn’t know that you are wanting something from the app variable inputWord.

When using JSON, you have to name a property that exists in the JSON response.

Here is the complicated part of your algorithm:

How will you determine that? The word is going to be TextInput’s Text. But what is the glossary? The JSON example you posted above has two terms, “Side diffuser” and “Sidepods.” That is not a full glossary. What does the full glossary look like? Is it that same format but with more terms?

If so, you will need to do this to get the list of terms:

Project link (see first screen): Thunkable

These blocks will search the JSON terms for one that matches exactly. So it will find “Sidepods” but not “sidepods” or “Sidepod”.

Thank you, Tatiang. You’ve been much of a help.
Glossary here means a JSON file.
Yes, this is not a full glossary, I chose just two terms for the simplicity. In reality, it may contain hundreds of words. See on the screenshot a page from a glossary (=thesaurus).


So, initially it’s not a JSON, but rather a table with words.

The overall idea is to create an online dictionary fully based on the thesaurus/glossary.
And yes, it would be better if this “dictionary” was able to provide with the non-exact search of the words linguistic forms (e.g. the typed forms like “Sidepods” - “sidepods” - “Sidepod” were all recognized by the code as the “Sidepods”), but let’s leave this issue for the next stage of development)).

Did the blocks I shared work for you? The find first occurrence of item block returns the number of the list item index that matches. So if Text_Input4’s Text is found as a list item, it will return that item’s position in the list. If it returns zero, it was not found in the list.

Thank you, again.
I decided to suspend this project. So, I didn’t try it to apply a new code.