arcpy.JSONToFeatures_conversion

926
6
Jump to solution
03-02-2022 08:50 AM
JamesCrandall
MVP Frequent Contributor

Can anyone spot the issue with this input .json file?

arcpy.JSONToFeatures_conversion fails in both a .py script and in ArcGIS Desktop 10.8.1 JSONToFeatures toolbox.

py script error: "EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host"

Toolbox error: no message specified but the process fails with the Background Processing window appearing stating the operations did not complete successfully due to error and to tell ESRI's GP team about it.

 

 

 

 

{
  "features": [
    [
      {
        "geometry": {
          "y": -81.3515715,
          "x": 27.941971
        },
        "attributes": {
          "location_timestamp": 1646081377,
          "vehicleName": "Truck1",
          "deviceId": "350200694388663"
        }
      }
    ],
    [
      {
        "geometry": {
          "y": -81.3515715,
          "x": 27.941971
        },
        "attributes": {
          "location_timestamp": 1646081388,
          "vehicleName": "Truck1",
          "deviceId": "350200694388663"
        }
      }
    ]
  ],
  "fieldAliases": {
    "location_timestamp": "location_timestamp",
    "vehicleName": "vehicleName",
    "deviceId": "deviceId",
    "OBJECTID": "OBJECTID"
  },
  "fields": [
    {
      "alias": "OBJECTID",
      "type": "esriFieldTypeOID",
      "name": "OBJECTID"
    },
    {
      "alias": "deviceId",
      "length": 50,
      "type": "esriFieldTypeString",
      "name": "deviceId"
    },
    {
      "alias": "vehicleName",
      "length": 50,
      "type": "esriFieldTypeString",
      "name": "vehicleName"
    },
    {
      "alias": "location_timestamp",
      "length": 8,
      "type": "esriFieldTypeDate",
      "name": "location_timestamp"
    }
  ],
  "displayFieldName": "vehicleName",
  "spatialReference": {
    "wkid": 102100,
    "latestWkid": 3857
  },
  "geometryType": "esriGeometryPoint"
}

 

 

 

 

 

1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

not sure about the extra set of square brackets on "features":

{
	"features": [{
			"geometry": {
				"y": -81.3515715,
				"x": 27.941971
			},
			"attributes": {
				"location_timestamp": 1646081377,
				"vehicleName": "Truck1",
				"deviceId": "350200694388663"
			}
		},
		{
			"geometry": {
				"y": -81.3515715,
				"x": 27.941971
			},
			"attributes": {
				"location_timestamp": 1646081388,
				"vehicleName": "Truck1",
				"deviceId": "350200694388663"
			}
		}
	],
	"fieldAliases": {
		"location_timestamp": "location_timestamp",
		"vehicleName": "vehicleName",
		"deviceId": "deviceId",
		"OBJECTID": "OBJECTID"
	},
	"fields": [{
			"alias": "OBJECTID",
			"type": "esriFieldTypeOID",
			"name": "OBJECTID"
		},
		{
			"alias": "deviceId",
			"length": 50,
			"type": "esriFieldTypeString",
			"name": "deviceId"
		},
		{
			"alias": "vehicleName",
			"length": 50,
			"type": "esriFieldTypeString",
			"name": "vehicleName"
		},
		{
			"alias": "location_timestamp",
			"length": 8,
			"type": "esriFieldTypeDate",
			"name": "location_timestamp"
		}
	],
	"displayFieldName": "vehicleName",
	"spatialReference": {
		"wkid": 102100,
		"latestWkid": 3857
	},
	"geometryType": "esriGeometryPoint"
}

View solution in original post

6 Replies
DavidPike
MVP Frequent Contributor

not sure about the extra set of square brackets on "features":

{
	"features": [{
			"geometry": {
				"y": -81.3515715,
				"x": 27.941971
			},
			"attributes": {
				"location_timestamp": 1646081377,
				"vehicleName": "Truck1",
				"deviceId": "350200694388663"
			}
		},
		{
			"geometry": {
				"y": -81.3515715,
				"x": 27.941971
			},
			"attributes": {
				"location_timestamp": 1646081388,
				"vehicleName": "Truck1",
				"deviceId": "350200694388663"
			}
		}
	],
	"fieldAliases": {
		"location_timestamp": "location_timestamp",
		"vehicleName": "vehicleName",
		"deviceId": "deviceId",
		"OBJECTID": "OBJECTID"
	},
	"fields": [{
			"alias": "OBJECTID",
			"type": "esriFieldTypeOID",
			"name": "OBJECTID"
		},
		{
			"alias": "deviceId",
			"length": 50,
			"type": "esriFieldTypeString",
			"name": "deviceId"
		},
		{
			"alias": "vehicleName",
			"length": 50,
			"type": "esriFieldTypeString",
			"name": "vehicleName"
		},
		{
			"alias": "location_timestamp",
			"length": 8,
			"type": "esriFieldTypeDate",
			"name": "location_timestamp"
		}
	],
	"displayFieldName": "vehicleName",
	"spatialReference": {
		"wkid": 102100,
		"latestWkid": 3857
	},
	"geometryType": "esriGeometryPoint"
}
JamesCrandall
MVP Frequent Contributor

Good eye.  Thank you! 

 

I'm attempting to transform a XML response from a non-spatial api that I've got to basically rebuild into well-formatted json and it looks like I've got an improper list-build process going on somewhere that generates the json.  Your correction looks like it should work.

0 Kudos
DavidPike
MVP Frequent Contributor

JSON drives me nuts.  Maybe ambitious to mark it as correct if not tested!

JamesCrandall
MVP Frequent Contributor

Well... if you're up to taking a stab at my list-build problem I can keep this thread going!  🙂

0 Kudos
DavidPike
MVP Frequent Contributor

Ah if it works as a step in a bigger problem I'll keep the solve.  Probably better to do a new thread for a new problem.  Would get more interaction also.

JamesCrandall
MVP Frequent Contributor

heh.... No problem.  Actually I think I've worked it out.  But yep my squigglies perception is about maxed out for the day!

 

Thanks for the answer it helped.

0 Kudos