cancel
Showing results for 
Search instead for 
Did you mean: 

Convert mysql DB Tabel to nested JSON

ccontzen
Deputy Chef II
Deputy Chef II

Dear all,

im trying to create a JSON file from a mySQL Database Table. 

the table looks like this:

ID|Street|City|Type|FirstName|LastName

1|Somewherestreet|Somewherecity|Familyhead|Chris|Somebody

1|Somewherestreet|Somewherecity|FamilyMember|Anna|Somebody

1|Somewherestreet|Somewherecity|FamilyMember|Frank|Somebody

the desired output should look like this

"ID":"1",

"Street":"Somewherestreet",

"City":"Somewherecity"

"Type": "FamilyHead",

"FirstName": "Chris",

"LastName": "Somebody",

"Members":[

{"FirstName": "Anna",

"LastName": "Somebody"},

{"FirstName": "Frank",

"LastName": "Somebody"}

],

"ID":"2",

....

 

Ho can i group the data and create a clean nested json? 

Any hint would be helpful

 

Regards,

Christian

 

1 ACCEPTED SOLUTION

marlon-muela
Workato employee
Workato employee

Hi @ccontzen 

You can use the data pill of the table output and use the formula .to_json to convert the value as a JSON output.

marlonmuela_0-1698669307746.png

 

View solution in original post

1 REPLY 1

marlon-muela
Workato employee
Workato employee

Hi @ccontzen 

You can use the data pill of the table output and use the formula .to_json to convert the value as a JSON output.

marlonmuela_0-1698669307746.png