Consider the following conversion from String
to Mathematica Expression:
n = 10;
ToExpression[Table["{", {n}] <> Table["}", {n}]]
{{{{{{{{{{}}}}}}}}}}
Everything is fine.
However, when the string is longer:
n = 510;
ToExpression[Table["{", {n}] <> Table["}", {n}]]
ToExpression::sntx: Invalid syntax in or before " <<182>> ^". $Failed
My actual string that I'm trying to convert is much longer, about 2 million characters. How can I convert it to a Mathematica expression? A short example is:
"{"GAME", {"version", "0.23.5"}, {"linkURL", ""}, {"Mode", "1"}, {"PARAMETERS", {"FLIGHT", {"CanQuickSave", "True"}, {"CanQuickLoad", "True"}}}, {"SCENARIO", {"name", "ScenarioDiscoverableObjects"}, {"scene", "7, 8, 5"}, {"", "703987854"}, {"sizeCurve", {"key", "0 0 1.5 1.5"}, {"key", "0.3 0.45 0.875 0.875"}}}}"
UPDATE
Read
ing a Stream
also fails:
n = 510;
string = Table["{", {n}] <> Table["}", {n}];
stream = StringToStream[string]
Read[stream, Expression]
Close[stream]
Read::readt: Invalid input found when reading {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\[Ellipsis] }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} from StringToStream[{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\[Ellipsis] }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]. >>
n = 510; ToExpression[Table["1+1+", {n}] <> Table["1+1", {n}]]
$\endgroup$ToString
that's stumbling. I've found another place where Mathematica has trouble with deeply nested lists. See this question. I would say it's a bug. $\endgroup$