I am calling a 3rd party API that performs and return a Google search. The return JSON contain a section for related searches. It has a list that is not in a format that Bubble can parse. It should be a list of key value pair, but it is just a list of values. What can I do to get that list?
Why do you say Bubble can’t parse? You have a list of text (items)
I think the problem is how you set API Connector for this field. Did you change the type to something else than list of text?
The return JSON has 4 different types on the same level. Bubble creates a structure that is inclusive of all types, except the simple structure of related searches. For the other 3 types, the “items” contains a nested list of structure. For the related searches, the “items” only contains a list of values. If instead of “items”, it uses an unique key, e.g. “search_terms”, then Bubble would be able to create a field for it. I have tested this myself with manual API response.
What I understand, is that the response is different from one call to another? In some case it’s a text array and some case it’s an array of object. Objects can have different fields. This seem to be related with the “type”
Am I right?
Yes, you are correct. The response can have up to 4 types each with its own structure. 3 of the types have “items” with an array of object. 1 type has items as an array of text, which Bubble doesn’t convert into a Bubble text list.
The problem is that you will not be able to process both in a single call. You could initialize one call with a merge of all objects/key possible in one array “type” and one array of text in another call. In both case, better to use “manually enter API response”
Another option is to get the JSON as text instead as JSON and use a JSON tool or regex
Thanks for your suggestions.
Just an update. JSON tool plugin won’t work. It has the same issue processing the JSON as Bubble. So I get the response in text instead of JSON and process it via Javascript. It is actually pretty easy and fast.