Parse Data, Strugling

I am trying to convert a text string to json, and I am strugling. i’ve tried all plugin, backend workflows, but for the life of me, I can’t make it work.

This is the text I am trying to convert:
{“supplement_1”:{“supplement”:“Vitamin B3 (Niacinamide)”,“daily_intake”:100,“unit_of_measure”:“mg”,“reason_to_take”:“Supports energy metabolism and skin health”,“time_of_day”:“morning”,“price”:0.0135,“price_unit”:“per mg”,“ingredient_cost”:1.35},“supplement_2”:{“supplement”:“Vitamin D3 (Cholecalciferol)”,“daily_intake”:20,“unit_of_measure”:“mg”,“reason_to_take”:“Supports bone health and immune function”,“time_of_day”:“morning”,“price”:0.0206,“price_unit”:“per mg”,“ingredient_cost”:0.412},“supplement_3”:{“supplement”:“L-Theanine”,“daily_intake”:200,“unit_of_measure”:“mg”,“reason_to_take”:“Promotes relaxation and stress reduction”,“time_of_day”:“morning”,“price”:0.0002,“price_unit”:“per mg”,“ingredient_cost”:0.04},“supplement_4”:{“supplement”:“Magnesium Threonate”,“daily_intake”:1500,“unit_of_measure”:“mg”,“reason_to_take”:“Supports cognitive function and sleep quality”,“time_of_day”:“night”,“price”:0.0004,“price_unit”:“per mg”,“ingredient_cost”:0.6},“supplement_5”:{“supplement”:“Rhodiola Rosea Root Extract”,“daily_intake”:500,“unit_of_measure”:“mg”,“reason_to_take”:“Enhances mood and reduces fatigue”,“time_of_day”:“morning”,“price”:0.02,“price_unit”:“per mg”,“ingredient_cost”:10},“supplement_6”:{“supplement”:“Omega-3 Fish Oil”,“daily_intake”:1000,“unit_of_measure”:“mg”,“reason_to_take”:“Supports heart health and brain function”,“time_of_day”:“morning”,“price”:0.03,“price_unit”:“per mg”,“ingredient_cost”:30},“supplement_7”:{“supplement”:“Ashwagandha Root Extract”,“daily_intake”:600,“unit_of_measure”:“mg”,“reason_to_take”:“Helps reduce stress and improve sleep”,“time_of_day”:“night”,“price”:0.0005,“price_unit”:“per mg”,“ingredient_cost”:0.3},“supplement_8”:{“supplement”:“Vitamin B12 (Cyanocobalamin)”,“daily_intake”:2.4,“unit_of_measure”:“mg”,“reason_to_take”:“Supports energy levels and nervous system health”,“time_of_day”:“morning”,“price”:0.05,“price_unit”:“per mg”,“ingredient_cost”:0.12},“supplement_9”:{“supplement”:“Coenzyme Q10 (Ubiquinone)”,“daily_intake”:100,“unit_of_measure”:“mg”,“reason_to_take”:“Supports energy production and heart health”,“time_of_day”:“morning”,“price”:0.0001,“price_unit”:“per mg”,“ingredient_cost”:0.01},“supplement_10”:{“supplement”:“Chamomile Flower Extract”,“daily_intake”:500,“unit_of_measure”:“mg”,“reason_to_take”:“Promotes relaxation and aids sleep”,“time_of_day”:“night”,“price”:0.03,“price_unit”:“per mg”,“ingredient_cost”:15},“supplement_11”:{“supplement”:“Valerian Root Extract”,“daily_intake”:300,“unit_of_measure”:“mg”,“reason_to_take”:“Improves sleep quality and reduces anxiety”,“time_of_day”:“night”,“price”:0.87,“price_unit”:“per mg”,“ingredient_cost”:261},“supplement_12”:{“supplement”:“Melatonin”,“daily_intake”:5,“unit_of_measure”:“mg”,“reason_to_take”:“Regulates sleep-wake cycle”,“time_of_day”:“night”,“price”:0.02,“price_unit”:“per mg”,“ingredient_cost”:0.1}}

If i add this text in an API for a backend:

If I copy and paste the text as a raw response, even without changing any formating, it give me the results I want to see…

Anyone can guide me? I’ve been stuck in this doom loop for 7 days!

Hmm :thinking: Good question.

I think, it might be easier to not send it as a parameter but maybe as the Body. Would that help?

It work when I send as a Body… the Backend WF is able to see the fields:

However, I can’t get it to send me the fields back as a response… :smiling_face_with_tear:

What exactly you want to achieve do you want to store the api response received to bubble database?

Yeah, I guess I am confused. Like what @VersaSync_Studios said. What is your goal here? There might be a better way to do this. :blush:

So,

I get the info from OpenAI

And I want to display the info in a Repeating Group, with the supplement, quantity, unit of measure and reason to take it…

Hmm :thinking: So this could change in structure each time? Or will it always be the same structure?

Structure is always the same!

So if you are now getting the response using the ‘Body’ can you now send it that way and get what you need?

I recommend creating a thing in your database called ‘Dev Log’ that saves the value you are getting back from OpenAI so you can see exactly what you are trying to convert to see if there are any errors. That way, you can check and see what is going on in the workflow without searching for the Bubble log for it.

I was able to get the response as a json, and I am amost there, however now I am struggling to make it show in a repeating group.

image

image

How can i make it understand?

If I drill down, and select one specific field, I can make it work.


But Ideally I want to choose what info i want to display in the text.

I’ve nested the JSON element under rec,


But now, I cannot make it return it as a respone.


how can i set up the backend workflow to send the rec list back?

Another test, another failure:

this gives me all objects toghether in the repeating group:

It looks like you are making some good progress troubleshooting. It gets a little tricky but if things are coming back as a list, then it should work in a repeating group. If it is a single item at the top, then make it a group outside of the repeating group. You might want to try to use it as ‘Data’ instead of displaying as a list as an ‘Action’. That way you can see how to make it on the page without waiting for a workflow to run.

Keep going! You almost got it! :blush:

even when i set up as a list,
This is what I get:

so the repeating group identifies everything as one item

I think I see what you mean, do you mean the supplement list?

If you want this as a repeating group, you can use ‘split by’ and then put a comma in there so you have a list of them in a repeating group.

Would that get you your desired outcome? :man_shrugging:

I’ve tried, it simple ignore the split by and show everything in the same cell

Hmm :thinking:

Can you share a screen shot of your repeating group data source?

Here, the workflow:

The Repeating Group

u

Repeating group text:

Outcome:

:smiling_face_with_tear:

Problem is here:
How the BW API gets the information:

How it sends back;