JSON formatting to bulk action via Data API

Hey guys, I have this sample format from CSV to JSON converter output:

[{“Index”:1,“Customer Id”:“DD37Cf93aecA6Dc”,“First Name”:“Sheryl”,“Last Name”:“Baxter”,“Company”:“Rasmussen Group”,“City”:“East Leonard”,“Country”:“Chile”,“Phone 1”:“229.077.5154”,“Phone 2”:“397.884.0519x718”,“Email”:“zunigavanessa@smith.info”,“Subscription Date”:“8/24/2020”,“Website”:“http://www.stephenson.com/"},{“Index”:2,"Customer Id”:“1Ef7b82A4CAAD10”,“First Name”:“Preston”,“Last Name”:“Lozano”,“Company”:“Vega-Gentry”,“City”:“East Jimmychester”,“Country”:“Djibouti”,“Phone 1”:5153435776,“Phone 2":“686-620-1820x944”,“Email”:"vmata@colon.com”,“Subscription Date”:“4/23/2021”,“Website”:“http://www.hobbs.com/”}]

I need to format that each object is in a line, such as:

{“Index”:1,“Customer Id”:“DD37Cf93aecA6Dc” (…)}
{“Index”:2,“Customer Id”:“1Ef7b82A4CAAD10” (…)}

This formatting is the required for having a DATA BULK action within the Data API.
Any ideas of how I can directly from the workflow manage to make some changes from the original output so that it is just as I described with 1 object per line?

Thanks

You can do a few find/replaces and you should be there. See below:

You see a couple of find/replaces:
image

First one to get rid of the first [:
image

And then the last ].

And finally, you will replace }, with } <newline>:
image

I added two newlines in the last one to show it clearly. You can put one.

Of course, be aware that if your json has spaces in between these things you will replace, it might be problematic.

See it here: Tests for Forum 13 | Bubble Editor

1 Like

This was very kind and instructive. Thanks @hergin I will try it out right now and come back later.

It does work. Thanks again!

1 Like

hergin, just a quick question. How would you add “Created by” user in this array of json objects which is actually received as a text to the bulk action? Thanks

I would do it here, right before } as ,"createdBy":"SomeUser". But of course if each json item has different created by, you might need to do some more tricks.

1 Like

Ow man, you’re an angel.
Thanks brother!

1 Like

Brother, unfortunately for that case it doesn’t work as I expected.
Because when I try to initialize the Data bulk call in the API connector with “user” datatype it just do not go through. Error appears.

The issue I’m having is this: when I create “Operations” datatype in bulk action with API connector I do not know how to associate every single of those operations to the actual “current user”. Even the “Created By” field remains empty.

In such case, how would you tackle this issue?

This is something else. Not related to the handling json. So I have no idea.

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