I’m struggling to find a good way to pass strings as JSON. Currently the JSON body in my api connector looks something like this { "firstName": "<firstName>", "lastName": "<lastName>"}
First name and last name are obviously strings, so I am wrapping them in quotes.
The issue is that if one of these values is empty, Bubble will return null, and the JSON will have the word null wrapped in quotes, as a string.
I see two options:
- Don’t wrap in quotes. This allows us to pass actual null values, but will cause a JSON error if the string has a space in it, so not a valid solution.
- Create a new step to populate every single field in the api call using it’s own when statement, and add the quotes to the string there if it is not empty
Option 2 would work, but with dozens of api calls with dozens of fields each, it’s a bit ridiculous. Does anybody have a better, maybe more scalable solution?