I have a string in Java like this:
String s = "{{\"2D\", \"array\"}, {\"represented\", \"in a string\"}}"
How can I convert it into an actual array? Like so:
String[][] a = {{"2D", "array"}, {"represented", "in a string"}}
(What I'm looking for is a solution a bit like python's eval()
)
[...]
, not{...}
. If it's really as simple as shown, of course the OP could do areplaceAll
first to change those over, but it's probably not actually as simple as shown. – T.J. Crowder Oct 27 '12 at 11:55String[]
and initialize it withString[][]
. If you don't know in advance the dimensionality of your array, this is not a simple problem at all. – Marko Topolnik Oct 27 '12 at 12:02