I have made this function:
conv01 = Map["["<>StringJoin@@Riffle[#,","]<>"]"&,Map[ToString,#,{2}],{0,1}]&
to convert:
list = {{1, 2, "test3"}, {3, 4, "test4"}}
to
"[[1, 2, \"test3\"], [3, 4, \"test4\"]]"
I know that I can do: conv02 = StringReplace[ToString[#], {"{" -> "[", "}" -> "]"}] &
but it's not safe if I have {
or }
inside it.
I have tried:
conv03 = Map["[" <> ToString@Row[#, ","] <> "]" &, list, {0, 1}]
but it doesn't work and I don't understand why if this works:
"[" <> ToString@Row[{1, 2, 3, 4}, ","] <> "]"
Some clue on the last method? Some idea of simpler solution?
{"{" -> "[", "}" -> "]"}]
rather than{"{" -> "{", "}" -> "]"}]
? Do I understand that your goal is to convert a Mathematica expression to a string, while replacing the list delimiters{
and}
with[
and]
? $\endgroup$dados
also should belist
in theconv03
line? $\endgroup$