How to send output data as JSON from script snap

Hi,

I am doing some transformation in script snap and some of the objects I want to send as is to downstream to store them as json in redshift, but when they are loading in redshift they are storing like {abc:234,pqr:[1,2,3]} i.e. they are not properly quoted. I have tried using json module in my script snap as I am using python, it didn’t work as I have nested structure coming and when you read the type of the objects coming it shows as java data types. Also, sometimes it is replacing “:” within json to “=” sign in the redshift.

Thanks

Apparently snaplogic makes no real distinction in the logic(within their software) itself. The values are merely passed as an object containing objects and, if they are flat, can be treated as CSV, etc… You CAN create arrays and the like, within a script object, and move them as if they were a normal variable. Snaplogic will handle everything at the lower levels. At least it does with python, but I am sure it works that way with other languages, etc… in snaplogic. If you do that, and treat it within the snaplogic designer GUI as if it is a normal value, you get the quoting that you mention. If you have an OBJECT that contains other objects, that can be arrays that contain arrays, etc… It will handle it in a way similar to any tool made to handle such things.

BTW DON’T bother making the output variable in your script different. You don’t have to name it differently, use punctuation, etc… It will just KNOW, based on how the variable is defined in your script And if you pull the value into an appropriately defined field in your script, and modify it, you can pass the changed value out, as if you had done nothing with it… Any parts that came in, under that variable, that you never changed, will go out unchanged.