Can I use the JSON module from ruby's stdlib and JSON.generate(...) on a ruby hash?
To answer my own question: It took me awhile to lock down the syntax. But I was able to use init and JSON.generate along with the map function to create a JSON string via the Ruby code block.
init => "require 'JSON'"
However one possibly very tricky problem remains.
My output now looks like
"body" : [
"{\"key1\" : \"value1\",\"keyn\" : \"valuen\"}",
"{\"key1\" : \"value1\",\"keyn\" : \"valuen\"}",
"{\"key1\" : \"value1\",\"keyn\" : \"valuen\"}"
]
That is each JSON object is wrapped inside a String in escaped syntax. I think it might be very difficult to extract each object from it's String wrapper because claims that LS needed Ruby to work with Arrays in the first place. However I will see if I can simply apply another filter to extract the String. I hope I can extract the String and complete this work quickly.