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]? – Mr.Wizard Dec 05 '13 at 18:50dadosalso should belistin theconv03line? – Mr.Wizard Dec 05 '13 at 18:53"test3"and"test4"; what do you intend? – Mr.Wizard Dec 05 '13 at 18:56{and}characters that occur within an internal string you can replace all of these with[and], correct? – Mr.Wizard Dec 05 '13 at 18:58InputForm) like:[[1, 2, "test3"], [3, 4, "test4"]]be OK or not? – Mr.Wizard Dec 05 '13 at 19:03