Best way to send nested JSON through API

I’m using Bubble to read and write JSON data to an external API and am trying to figure out how to include dynamic fields without too many conditionals. For example, I have a list of user-profiles with varying fields.

[
{
“name”:“Mrs. Wormwood”,
email":"wormwood@example.com”,
“role”:“Teacher”,
“subjects”:[
“Math”,
“Science”
]
},
{
“name”:“Moe”,
“role”:“bully”,
“favorite-food”:[
“knuckle sandwich”,
“dirt”
]
},
{
“name”:“susie derkins”,
“repulsive”:true
}
]

In bubble I have fields [name, email, role, subjects, favorite-foods, repulsive], but I don’t want to have a super long chain of conditions because I’m adding new fields regularly.

Is there any way I can dynamically generate this JSON in the bubble client and send plain json text to api instead of bubble objects and build on the backend?

Would this help? https://bubble.io/plugin/json-machine-1596550286614x704580898847195100

Thanks @cmarchan. I had checked it out briefly but figured I’d throw the question out there before invest time into learning how to use it. Will dig in deeper and if it’s helpful. Appreciate the response

1 Like

This is exactly what I’m looking for. Thank you! Note to self… read the docs

I had found this thread when I was trying to solve my problem, but this didn’t quite work out. I figured out a different approach that I thought might be useful to share here:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.