# Error importing JSON in 11.3 (worked in 11.2)

EDIT : Originally posted as an XML issue, file format was found to be actually JSON, yet the problem is essentially the same: Import worked in 11.2 but not in 11.3. As per Hans' comments, replicated in 11.2.

This JSON file was extracted from PDF. In 11.2 import worked correctly (was able to save it as MX file). (It’s available via this Google drive link since it’s over 10MB)

Tried Import w/ no options, with option "JSON", "RawJSON", and "ExpressionJSON" - as well as ImportString - all failed in 11.3.

The original PDF is found here.

• @alanccalvitti Are you sure what you posted to google drive is an XML file. It looks like JSON or JSON-like format. – Hans May 17 '18 at 23:44
• In v11.2 Import["DMAT201708.json"] took ~14 sec to display the entire contents. Redundant formatting text abound. – Hans May 17 '18 at 23:57
• Depending on version of Acrobat reader you should be able to save the pdf file to text. That particular file is throwing "Import::general: Expected cross reference table" error. – Hans May 18 '18 at 0:43
• @Hans, that does look like JSON, but Import w/ "JSON", "RawJSON", and "ExpressionJSON" - as well as ImportString - all failed in 11.3 But you were able to import as "JSON" in 11.2? If so, maybe I can just change the title XML-->JSON. (The redundant formatting is indeed there around every word, that's the way it was written). – alancalvitti May 18 '18 at 15:54
• Currently using 11.2. I did change the extension. Because of the dimensions of this list it does not display nicely. Mathematica struggles with formatting and display of the contents. The original PDF file is 1.47 MB, I was able to export to text at 773 KB using Acrobat Reader DC all on Windows. Export to RTF ballooned to 9 MB using Acrobat Pro on Mac. – Hans May 18 '18 at 18:30

There is a way to fix the invalid UTF8 using:

FromCharacterCode[ToCharacterCode[_String, "UTF-8"]]


Then use ImportString on the result.

In[13]:= importedjson = ImportString[FromCharacterCode[
ToCharacterCode[
Import["/Users/aarone/Desktop/DMAT201708X.xml", "String"],
"UTF-8"]], "RawJSON"];

In[14]:= importedjson[[;; 1, 1 ;; 3]]

Out[14]= {<|"number" -> 1, "pages" -> 394, "height" -> 1188|>}

• are you using 11.3? I copy-pasted your code and using my local copy of that xml file I get this error: Import::jsonhintposandchar: An error occurred near character '?', at line 1:3 – alancalvitti May 22 '18 at 16:17
• Yes, I just checked and I did this in 11.3. – Aaron Enright May 22 '18 at 16:22
• OS? I'm on High Sierra. – alancalvitti May 22 '18 at 16:23
• Same OS here. I get the error you get when I try to import the file directly from the URL. – Aaron Enright May 22 '18 at 16:24
• Interesting, but I'm not using the URL, I have the local copy DMAT201708X.xml – alancalvitti May 22 '18 at 16:37