cancel
Showing results for 
Search instead for 
Did you mean: 

Convert data from SQL select to JSON

peter
New Contributor III

What is the best way to take data from a SQL Select statement and convert to JSON so that it can be used in a API put commend?

1 ACCEPTED SOLUTION

Hi @darshthakkar,

Based on the screenshot provided, I created a dummy JSON and used extend expression in Mapper to add an extra layer.

Input JSON:
image

Mapper Expression:
image

Final Result:
image

Pipeline:
Test_Expression_2023_06_18.slp (3.5 KB)

I hope this helps.

Cheers 🙂

View solution in original post

5 REPLIES 5

RogerSramkoski
Employee
Employee

Hello Peter, welcome to the SnapLogic Community! SnapLogic is a JSON-based platform so what that means to you while working in the Designer is that every snap with a circular input or output is communicating through JSON, including the SQL Server Select snap results or a SELECT statement written in SQL Server Execute snap. Here’s a screenshot example:
image

peter
New Contributor III

Great that worked a treat.

Thanks

darshthakkar
Valued Contributor

@rsramkoski - can we add one more layer to this JSON structure? If yes, how could we do that?
I tried using Group By N with Group Size = 1 however I’m not getting the desired output.

Screenshot after using Group By N:
image

Desired Output:
image

Need to add one more layer so that the JSON output becomes nested.
Thanking in advance for your help.

Regards,
Darsh

Hi @darshthakkar,

Based on the screenshot provided, I created a dummy JSON and used extend expression in Mapper to add an extra layer.

Input JSON:
image

Mapper Expression:
image

Final Result:
image

Pipeline:
Test_Expression_2023_06_18.slp (3.5 KB)

I hope this helps.

Cheers 🙂