thomas-sh4u
thomas-sh4u•4mo ago

how can PowerShell returns an json array?

Is there a way that powershell return an json arry? I have written a script, that gets aa json array from an restful api. but when i wrote Write-Output $result (the array of json), the return value of the powershell script is on "]" 😦
9 Replies
thomas-sh4u
thomas-sh4u•4mo ago
i found the answer in the docs 😉 output must writen to the file ./result.json hm, but it does not work 😦
rubenf
rubenf•4mo ago
I will investigate, it should work
thomas-sh4u
thomas-sh4u•4mo ago
it seems that the result.json is not read as result of the step. is there a working sample?
rubenf
rubenf•4mo ago
Did you write it at ./result.json ? Or maybe somewhere else Could you print the full path where you wrote
thomas-sh4u
thomas-sh4u•4mo ago
here a code snippet: $jsonData = @{ "name" = "John Doe" "age" = 30 "city" = "New York" } | ConvertTo-Json '# the last line of the stdout is the return value $jsonData | Out-File -FilePath "./Result.json" lowercase is not running also: $jsonData | Out-File -FilePath "./result.json" any news here? I have no idea what i can test here.
rubenf
rubenf•4mo ago
i've pushed a fix, it will be available in next version
thomas-sh4u
thomas-sh4u•4mo ago
okay, great.
rubenf
rubenf•4mo ago
No description
thomas-sh4u
thomas-sh4u•4mo ago
yeah, it run's 🙂 can you gibe me a hint, how should the follow task? i have multiple powershell scripts that getting information from different api's, each script returns a json. should i create one workflow and put each of the script there or is it better to use multiple schedules with multiple workflows? oh each workflow is only a powershell scipt and an "store to elasticsearch" python-script.