How to save dmn result variable as json

i want to save the result of a dmn into a json variable (hit policy=collect) by using the ‘business rule task’ object in order to call the dmn. the easiest way i guess would be to somehow transform it with javascript. any idea how to solve it that way?

input / output of the dmn
‘A’ / ‘B’
‘A’ / ‘C’

desired result:
processinstanceVariable = ["B, “C”]

use a output mapping to run a script to convert from a java collection/array into a SPIN variable.