Skip to content

Instantly share code, notes, and snippets.

@fongd
Created September 5, 2017 14:21
Show Gist options
  • Save fongd/05dfb7de2e1ededb2e12e97fb2152f17 to your computer and use it in GitHub Desktop.
Save fongd/05dfb7de2e1ededb2e12e97fb2152f17 to your computer and use it in GitHub Desktop.
JSON result that causes problems with Swift 3.1 - "The data couldn’t be read because it isn’t in the correct format."
{
"messages": [],
"results": [
{
"dataType": "GPFeatureRecordSetLayer",
"paramName": "Route",
"value": {
"displayFieldName": "",
"exceededTransferLimit": false,
"features": [
{
"attributes": {
"FirstStopID": 159,
"LastStopID": 160,
"Name": "Location 1 - Location 2",
"ObjectID": 1,
"Shape_Length": 0.2018457022292753,
"StopCount": 2,
"Total_Length": 18535.186900310175
},
"geometry": {
"paths": [
[
[
-60.30262770699994,
46.24573219500007
],
[
-60.30722033599994,
46.240915606000044
],
[
-60.31239534699995,
46.22904968900008
],
[
-60.324733325999944,
46.21983896900008
],
[
-60.33384357699998,
46.21686904500007
],
[
-60.352467383999965,
46.21608216700008
],
[
-60.368167608999954,
46.213624320000065
],
[
-60.388877383999954,
46.203454418000035
],
[
-60.40122284199998,
46.19207621800007
],
[
-60.42459549499995,
46.15287720600003
],
[
-60.429185459999985,
46.15046567500008
],
[
-60.443932108999945,
46.148559187000046
],
[
-60.45893517199994,
46.140187549000075
]
]
]
}
}
],
"fields": [
{
"alias": "ObjectID",
"name": "ObjectID",
"type": "esriFieldTypeOID"
},
{
"alias": "Name",
"length": 128,
"name": "Name",
"type": "esriFieldTypeString"
},
{
"alias": "FirstStopID",
"domain": {
"mergePolicy": "esriMPTDefaultValue",
"name": "FirstStopID",
"range": [
0,
2147483647
],
"splitPolicy": "esriSPTDefaultValue",
"type": "range"
},
"name": "FirstStopID",
"type": "esriFieldTypeInteger"
},
{
"alias": "LastStopID",
"domain": {
"mergePolicy": "esriMPTDefaultValue",
"name": "LastStopID",
"range": [
0,
2147483647
],
"splitPolicy": "esriSPTDefaultValue",
"type": "range"
},
"name": "LastStopID",
"type": "esriFieldTypeInteger"
},
{
"alias": "StopCount",
"domain": {
"mergePolicy": "esriMPTDefaultValue",
"name": "StopCount",
"range": [
0,
2147483647
],
"splitPolicy": "esriSPTDefaultValue",
"type": "range"
},
"name": "StopCount",
"type": "esriFieldTypeInteger"
},
{
"alias": "Total_Length",
"domain": {
"mergePolicy": "esriMPTDefaultValue",
"name": "Total_Length",
"range": [
0,
1e+308
],
"splitPolicy": "esriSPTDefaultValue",
"type": "range"
},
"name": "Total_Length",
"type": "esriFieldTypeDouble"
},
{
"alias": "Shape_Length",
"name": "Shape_Length",
"type": "esriFieldTypeDouble"
}
],
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"latestWkid": 4326,
"wkid": 4326
}
}
}
]
}
@fongd
Copy link
Author

fongd commented Sep 5, 2017

The notation in line 145 ("1e+308") triggers the following error when attempting to parse this JSON via JSONSerialization.jsonObject(with:options:):

"The data couldn’t be read because it isn’t in the correct format."

However, this JSON is syntactically correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment