You need to restructure the data to accommodate your search. Using an object you can assign each book title as a property name and assign that property a list of the cities that are associated w/ the book title.
This is the JSON I simulated from your images:
{“city”: {“kolhapur”:{“library1”:[“48 laws of power:”,“founder’s office:”]},“mumbai”:{“library2”:[“founder’s office:”,“the motive:”]},“pune”:{“library3”:[“48 laws of power:”,“the motive:”]}}}
I refactored the JSON to use the following:
{“city”: {“kolhapur”:{“library1”:{“48 laws of power”:,“founder’s office”:}},“mumbai”:{“library2”:{“founder’s office”:,“the motive”:}},“pune”:{“library3”:{“48 laws of power”:,“the motive”:}}}}
After updating the JSON I got the null value as well, and then I modified the blocks to get the object properties and it worked again.
It still seem to show null even after adding the get object properties block
do you think it might have something to do with my firebase database settings?
@itsvedanttikareztlgx I don’t think the issue is w/ your firebase settings, but rather the data schema… I’ve not used firebase a lot, so I don’t know if this is normal for firebase, but the data structure seems to be off, or because I don’t see the full scope of the data I think it’s off, and I’m guessing based on the images you’ve provided.
The values you’re seeking are the object properties, and it’s as if none of your data is actually stored in the values.
I would expect the data to be structured more like:
With the structure above your code blocks become a lot easier to read and manage because now you can target the direct property name instead of trying to find the properties in the objects and hope it’s the right data you’re looking for.
I don’t know if you have full control over the data, and how it’s structured, but getting the data as values of the properties vs using the properties as values may be the first step to resolve these issues and future issues.
Using the restructured data schema I refactored the blocks just to show you how much easier it is to read and follow the logic when you can access your data values directly.
So the search feature works hurray!!
thanks a lot for the help
Now I need to figure out how can I restructure firebase database, because it worked when I imported your JSON to my firebase database. But there are multiple layers to what I’m trying to do.
so there will basically be 3 layers City > library > books
now the way I want the app to work is, when you enter the app you choose the city you are in
let’s say Mumbai for now
so once that is choosen now user only accesses data in mumbai segment of the database and so Mumbai > Libraries > books
later user searches for a book
and user gets a result of all the libraries that contain that book
and so say user looks for the motive
Now every library that has “the motive” will show up in list
and when clicked on any one library
A profile page for that particular library opens.
from where user can either go through google maps link provided in it
OR
check out the catalogue of that library, and find other books the library has
the reason I’m telling the whole thing is so you can have better understanding of what I’m trying to do.
Maybe do a search and look up how to structure your firebase data.
Here’s a quick primer on JSON
{} Curly braces represent an object with named properties
Square brackets represent an array with numerically indexed properties. The index starts at 0.
: Colons separate “Key”:“Value” pairs, and need to be surrounded by double quotes
Strings are alphanumeric and must be surrounded by double quotes
Integers & Demicals are numbers and don’t require double quotes
Boolean are true or false and don’t require double quotes
Okay will have to look up how exactly can I use the firebase’s low code database structuring, because I will later also have to create an independent system to upload city and library data. To make registering libraries on app easier.
If you are structuring JSON for use with Thunkable, I recommend asking ChatGPT or Microsoft Copilot to suggest a format for your data. I found that to be helpful when I was creating an ideal Firebase realtime database structure.
Hey, so based on your responses I created a new JSON with the help of Gemini AI. Now the JSON that Gemini created was the exact way the app would have it’s structure.
Now I need help understanding how can I create what we created here
based on the new JSON
(I have color coded specific things in doc to make it easier to read)
and also how I can adjust the blocks for search feature
The key to setting these up, is that each time you move down a level in the JSON you have to create a loop to access each of the items.
In the blocks I setup, I’ve been isolating each new level as a “temp” variable that will be changed each time the loop iterates.
In your previous JSON examples the book titles were all lower case, in this one they’re Title Case. So I suggest changing the case of the book title when saving it to the booList object and converting the search term both to lowercase, so you can do an exact match.
What I was finding during testing was that Thunkable is looking for the exact match:
The Shadow of the Wind != the shadow of the wind
You can Integrate ChatGPT for Complex Search in JSON, If you use ChatGPT, You have just to send JSON, with Some prompts of the Search Term or Similar ( with some prompt engineering ) and it will give the Outputs of the Search.
If you want to it with this way, DM me as I can personally help you with this.
@itsvedanttikareztlgx wow that was a lot to digest, and I’m not sure I followed all of what you were asking for, but I created this mock up for you to look at:
This mockup has four screens Cities, Libraries, Books and Book Details.
On each screen you select the item from the list, that item is stored in a var.
By the time you reach the book details, there will be a selected city, library and book title.
Then we look in the original data source to find the book details looping through the data down to the selected book in the selected library of the selected city.
I’ve configured the blocks in the mock up to “continue with next iteration” if the secelected var doesn’t match the current object, and when it does, it will “break out of loop”. Which means it will skip any data that doesn’t match the selectedVars and when it does find it, it will stop looking and move on.
This mock up doesn’t include your original search for the book title. I would leave that code alone.