Bug present in 10.0.2 or earlier, and fixed in 10.4
If I try to export this toy code as ExpressionML
or just XML
:
data1 = {1, 2, 3, Plot[x, {x, 0, 10}]};
str1 = ExportString[data1, "ExpressionML"];
ImportString[str1]
I have no problem. Executing it, I get as expected:
But if I try to export some expression containing as Association
like this:
data2 = {1, 2, 3, <|"a" -> 4, "b" -> 5|>};
str2 = ExportString[data2, "ExpressionML"];
(*ImportString[str2]*)
I get:
So, I can't export Associations
. This is a bug no? Tested in Mathematia 10.0.2 for MAC.
UPDATE
A very clumsy workaround that I did was:
data3={1,2,3,<|"a"-> 4,"b"-> 5,"c"-><|"a"-> 4,"b"-> 5|>|>};
str3=ExportString[data3/.Association-> AssociationTemp,"ExpressionML"];
ImportString[str3]/.AssociationTemp-> Association
Note that for nested Associations
, Replace
works properly just from V10.0.2