I'm using arcpy.JSONToFeatures_conversion() to batch convert some json files to features in a gdb. Python kept running into errors (either ERROR 001558: Error parsing json file, or ERROR 999998). This was troubling since I had previously tested the input/output without issue. After a lot of troubleshooting I found the error only occurs after the json module was imported. What is the most pythonic way of dealing with this? Can anyone explain the conflict and how I might recognize/anticipate this when troubleshooting code in the future?

Full error:

Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
    arcpy.JSONToFeatures_conversion(in_json_file, out_features)
  File "C:\ArcGIS\Desktop10.3\ArcPy\arcpy\conversion.py", line 528, in JSONToFeatures
    raise e
ExecuteError: ERROR 001558: Error parsing json file 'L:/<dir>results16870.json'. 
Failed to execute (JSONToFeatures).

Code Snippet (works when json isn't imported):

import arcpy
import json
temp_json = r"~\result1216.json"
fcName = r"~\Testing.gdb\newFC"
arcpy.JSONToFeatures_conversion(temp_json, fcName)

Screen shot of code/process and error (note the same input/output): enter image description here

  • Just shot in the dark. The import json could be in conflict with another module with the same name. Try using “import json as jsonlib” or something to that effect so it doesn’t use the json namespace – PMK Apr 11 '18 at 13:59
  • 1
    Please always provide code snippets as formatted text rather than pictures. – PolyGeo Oct 17 '18 at 22:16
  • can you copy/paste the json into jsonlint.com and confirm its valid? – KHibma Oct 18 '18 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.