I’m struggling to convert a JSON with nested values into entries in my database using backend workflows or APIs.
I’ve looked around this forum, played with trying to make a plug-in, but still can’t figure it out. So this is a call for help please in the hopes someone has done this already!
If I start with a JSON like this:
[
{ “item1”: { “nestedKey1”: “nestedValue1” } },
{ “item2”: { “nestedKey2”: “nestedValue2” } },
{ “item3”: { “nestedKey3”: “nestedValue3” } }
]
How can I turn that JSON with 3 items, into three separate database entries where the nestedKeys are a field in the database?
The approach I’ve tried is to create a plug-in with backend actions to turn the JSON into a bubble-friendly list, with the intention of running an API workflow on that list to get it into the database.
But I can’t figure out how to turn the JSON into a bubble-friendly list using backend actions of a plugin.
that’s not jerky. I have tried the forum and a few different plugins and am still struggling. I’m not sure what I’m missing here. There’s a lot of questions about JSON, but I can’t find anything around how to use backend workflows with JSON to get items into a database. Especially nested JSON items into database fields
Thanks @amer ! I had checked this one out before as well and given it a shot.
I think the issue I’m having is that I want to turn this:
[
{ “item1”: { “nestedKey1”: “nestedValue1” } },
{ “item2”: { “nestedKey2”: “nestedValue2” } },
{ “item3”: { “nestedKey3”: “nestedValue3” } }
]
Into three database entries, each of which have a field called “JSON” that should have:
Entry 1. { “item1”: { “nestedKey1”: “nestedValue1” } }
Entry 2. { “item2”: { “nestedKey2”: “nestedValue2” } }
Entry 3. { “item3”: { “nestedKey3”: “nestedValue3” } }
And each of those JSONs may have different keys and structures.
I’m looking into it more, and I realise the issue I’m having may be that ‘raw body text’ - which I think I could use - doesn’t actually get returned properly, so all I’m getting is ‘nulls’.
Looks like it may be a bug or I’m doing something wrong. Will dig into it deeper:
Hey! I created a plugin that took in the JSON, and parsed it into an object, and then returned the different key-values.
I’ve also accomplished something similar using the ‘JSON Assistant’ plugin. In retrospect, I’d probably use the ‘JSON Assistant’ plugin next time as that works well.