Trouble retrieving the recipe from spoonulacular API (using teachable machine)

You can try to manipulate the response received to delete all those malformed parts:

the question is if for other request you will have responses with other weird fields....
For example, with the above example of @ABG this example will not work...

(EDIT: I have changed the example by other more generic)

Other option could be extract the info directly from the response string but this can be quite cumbersome depending on the information you want to extract.

I'm so sorry, I made a mistake. These fields without values ​​are due to the fact that when you copied the JSON that you have left, the empty fields [ ] have been pasted as and then they have not been pasted correctly in my example. Apologies. By removing that part of "length" you should be able to decode it correctly:

1 Like

Thank you for your reply buddy. :blossom: :dizzy: Will this work though for different recipes? since my app will take different variables based on the users preferences and have the API retrieve recipes for them. I will continue working on my app and i will see if your code fixes the problem.<333

Looking to the @ABG examples:

name": "pandan leaves click here cut to 2\" length",

you can se the double quotes after the 2 are escaped (2 \ ")...in what you have pasted that double quotes are not escaped (2").

This difference is why you have to put that first additional block removing "length "".

But if your response have that double quoted escaped like in the other examples (maybe other error copy-pasting) then you don't need that additional block.

It is important to find out that because what works for one scenario will not work for the other so, try without the additional block:

1 Like

I will try both and tomorrow I will show you the results. thanks! <33 :herb:

Sorry for the mistakes... :pensive:

1 Like

I found the recipe JSON unparseable using the DecodeJSONAsDictionaries block, but the older DecodeJSON block was able to parse it without errors, albeit into lists of pairs.

So here is some rudimentary browsing and display code:

spoonacular.aia (7.5 KB)


I leave it up to you to prettify the output.

1 Like

I forgot I had this in stock for displaying structures by indentation:
tidy_JSON.aia (4.4 KB)


2 Likes

another way to pretty jsonString:

draggable:

3 Likes

One last note about spoonacular recipes.

I didn't see anything about preparation instructions.

Maybe they just do salads?

2 Likes

don't say that friend! you've done more than enough to help me thank you! <33

1 Like

I think its because the ingredients that i use for this app are mostly fruits and veggies. :grapes: :watermelon: :strawberry: :blueberries:

I really want to thank you guys @ABG @NishyanthKumar @Kevinkun @Ramon for helping me so much with this and being so kind too! :blossom: i want to show you were i got, and i think you'll be very proud! :dizzy: i managed to translate the Json text after organizing it like you showed me and now i can receive the titles and the steps of the recipies like i wanted :partying_face: :partying_face: i will show you the code and the screen (in the companion app):


up until here it all works like a charm! and i think i am finally understand the basic of dealing with dictionaries :partying_face: the only problem i may be facing is splitting the recipes apart (their titles and steps("original") i am currently working on fixing that wish me luck!


this is the screen :

Once i am done with this app i will put the entire app (.aia) here so everyone can use it and i will add your names for your help! :slight_smile: :smile: :blossom:

2 Likes

(added to FAQ)

3 Likes