How to change JSON to FM List and back again

I’m storing my form questions in a repeating field within FM.

I’m in a spot where I need the JSON being passed from BF into FM to be converted to an FM list so that the user can also use/edit the form within my FM solution.
Conversely, when the BF form is requested, the FM list needs to be converted back to JSON

My data is being pulled into BF just fine as I’ve set up a model.form.TextQuestionEnglish[x] array that gets parsed out in my JSON blocks.

Here’s the point where my data from BF is getting set in FM

Set Variable [$responseList ; Value: JSONListValues ($$BF_Model ; "form.textReponse")]
Set Variable [$x ; Value: ValueCount ($responseList) ]
Set Variable [$i ; Value: 0]

Loop
Set Variable [$i ; Value: $i +1]
Exit Loop If [$i > $x]
Set Field [SEL_CaseForm::textResponseEnglish[$i] ; GetValue ($responseList ; $i)
End Loop

In the repetitions where the data is multiple choice, the responses come in as ["ChoiceA", "ChoiceB", "ChoiceC"]
The reps that are single words, the responses simply get set as ChoiceA.

Anyone have any suggestions on how to convert the JSON to an FM List (¶ separated list)?

Conversely, I need to convert the FM List to JSON on the onFormRequest hook.

Did you ever resolve this issue?

There seem to be some custom functions that can handle this, for example: FileMaker Custom Function: JSONExplode ( JSON )

At the bare minimum, you can run a substitute on the array that replaces parts of the array into a list, something like:

image

Let ( 

~JSON = "[A, B, C, D]"; 

Substitute ( ~JSON; 
[", "; "¶"];
[","; "¶"];
["["; ""];
["]"; ""]

)

)

This is a simple implementation of this, the custom function has a more robust substitution that you can reference.

EDIT: With quotation substitution:

Let ( 

~JSON = "[\"A\", \"B\", \"C\", \"D\"]"; 

Substitute ( ~JSON; 
[", "; "¶"];
[","; "¶"];
["["; ""];
["]"; ""];
["\""; ""]

)

)