How do I create a JSON string from an Array?

serialization
json
string

#1

Hello, So I see plenty of examples on how to take an JSON string the bot got from another service and deserialize it into an array for it to process.

But I’m trying to go in the other direction. My bot has gathered various bits of information into an array and I want to encode that into a single JSON string that it can then pass out to the next service to handle.


#2

Hi @Kit_Ramos

You could try to loop through your array and save the data following json syntax. It shouldn’t be that complicated.


#3

Hi, @loginerror
Do you have any example of what you wrote?


#4

Unfortunately, I do not have it on hand.

I did find a feature request with a suggestion on how to proceed:

You could use the JSONConvert.SerializeObject() from Newtonsoft.Json together with the Invoke Code activity.

I hope it sets you on the right track.