This is unfortunately not an answer, but an extended comment that outgrew the comment form. In short, this might be a bug in ExportString
.
I am using Mathematica v. 10.1.0 on Windows 7 - 64 bit. Here's what I tried so far.
I tried to export your JSON content to a file, using the same format you proposed. This works just fine.
Export["fromExport.json", {"1" -> "Conexión"}, "JSON"]
Import["fromExport.json", "JSON"]
(* Out: {"1" -> "Conexión"} *)
The JSON file generated above also contains the same information:
{
"1": "Conexión"
}
I tried other strings, and other diacritics: no problems here.
Although I have typically found Export
and ExportString
to behave very similarly, in this case ExportString
fails as you showed on my system as well.
It doesn't seem to be a front-end problem either (i.e. the output is correct, but the front end messes up when formatting it for display). I tried to write the generated string out to a file, and it's still messed up:
stringout = ExportString[{"1" -> "Conexión"}, "JSON"];
filestream = OpenWrite["fromWriteString.json"];
WriteString[filestream, stringout];
Close[filestream];
Import["fromWriteString.json", "JSON"]
(* Out: Import::fmterr: Cannot import data as JSON format. *)
As you said, the JSON string generated is invalid. For completeness, on my system the fromWriteString.json
file contains:
{
"1": "ConexiA~\263n"
}
Hope this helps!
ExportString
(see my extended comment below as well). Would you contact Wolfram support to see what they think? $\endgroup$ExportString
doesn't acceptCharacterEncoding
like that works well inExport
, not only theJSON
, alsoHTML
,I've tried @ windows 8.1 and Mma 10.1 $\endgroup$ExportString[<|"1" -> "Conexión"|>, "RawJSON"]
$\endgroup$