Lottemint / json-to-bubble-object

Convert a JSON object to a Bubble object for plugin purposes. (Bubble.is)
14 stars 7 forks source link

Issue if JSON is directly an array #5

Closed jicihome closed 3 years ago

jicihome commented 3 years ago

If the json start directly with array, the script will fail to convert. Example: [{ "id": "683074", "gameUID": "1189705", "sport": "Football", "league": "NFL", "sportsbook": "Bovada", "startDate": "2020-11-15T21:05:00Z", "awayTeam": "Denver Broncos", "homeTeam": "Las Vegas Raiders", "description": "Denver Broncos vs Las Vegas Raiders", "isLive": "1", "changedDate": "2020-11-16T00:06:02Z", "checkedDate": "2020-11-16T00:06:07Z" }, { "id": "228853", "gameUID": "2898217", "sport": "Football", "league": "NFL", "sportsbook": "Bovada", "startDate": "2020-11-15T21:05:00Z", "awayTeam": "Los Angeles Chargers", "homeTeam": "Miami Dolphins", "description": "Los Angeles Chargers vs Miami Dolphins", "isLive": "1", "changedDate": "2020-11-15T23:59:01Z", "checkedDate": "2020-11-16T00:06:07Z" }, { "id": "392771", "gameUID": "6894794", "sport": "Football", "league": "NFL", "sportsbook": "Bovada", "startDate": "2020-11-15T21:05:00Z", "awayTeam": "Buffalo Bills", "homeTeam": "Arizona Cardinals", "description": "Buffalo Bills vs Arizona Cardinals", "isLive": "1", "changedDate": "2020-11-16T00:06:02Z", "checkedDate": "2020-11-16T00:06:07Z" }]

Lottemint commented 3 years ago

Hey @jicihome! 👋🏻

You need to run a loop through your array:

let data = [{"name": "1"}, {"name": "2"}, {"name": "3"}];
let converted = [];

data.forEach(cell => converted.push(convert(cell)));

console.log(converted);
jicihome commented 3 years ago

Thanks. I found a different workaround (setting my array into an object) The convert work on it, but Bubble doesn't seem to accept the result for now.

Lottemint commented 3 years ago

but Bubble doesn't seem to accept the result for now

Can you please share the error message?

Lottemint commented 3 years ago

I'm closing this thread.

Please open a new one if your issue still exists.

jicihome commented 3 years ago

I think I found the issue but didn’t get time to test for now. Thanks for your help 😉