Hi everyone,
I’m building a REST API in Bubble, and I’m trying to structure my JSON response properly. Right now, I can return a flat JSON structure like this:
{
"status": "success",
"response": {
"id": "1737909536227x470169112085528600",
"en_name": "Sweet Potato and Mushroom Egg Bake",
"fr_name": "Gratin aux Oeufs, Patate Douce et Champignons",
"kcal": 351,
"proteins": 17,
"carbohydrates": 46,
"fats": 11,
"fiber": 7
}
}
But I want to return a more structured JSON with nested objects, like this:
{
"status": "success",
"response": {
"id": "1737909536227x470169112085528600",
"name": {
"en": "Sweet Potato and Mushroom Egg Bake",
"fr": "Gratin aux Oeufs, Patate Douce et Champignons"
},
"nutrition": {
"kcal": 351,
"proteins": 17,
"carbohydrates": 46,
"fats": 11,
"fiber": 7
}
}
}
Problem:
In the Bubble backend workflow, when using “Return Data from API,” I don’t see an option to create nested JSON objects. The closest workaround I’ve found is returning the entire JSON as a text field, but that results in a string instead of a proper JSON object.
Question:
Is there a way to structure the API response properly in Bubble without treating it as a text string? How can I create nested JSON objects directly in the API response?
Any guidance or best practices would be super helpful! Thanks in advance.