I was under the impression that I can always deserialize CIM objects using json copied from a .lyrx file.
Is this true?
I created an SQL Query Layer with the UI, then saved it to a .lyrx file (see attached).
I then created a new file, sqldataconn1.json (see attached), with this json copied from the lyrx file:
{
"type" : "CIMSqlQueryDataConnection",
"workspaceConnectionString" : "SERVER=localhost;INSTANCE=sde:...",
"workspaceFactory" : "SDE",
"dataset" : "db1.DBO.%mytest2",
"datasetType" : "esriDTFeatureClass",
"sqlQuery" : "select OBJECTID,SHAPE,GDB_GEOMATTR_DATA from db1.dbo.TEST2",
"srid" : "3857",
"spatialReference" : {
"wkid" : 102100,
"latestWkid" : 3857
},
"oIDFields" : "OBJECTID",
"geometryType" : "esriGeometryPolygon",
"extent" : {
"xmin" : -11607361.9631999992,
"ymin" : 3260858.89570000023,
"xmax" : -10527607.362,
"ymax" : 3930306.748499997,
"spatialReference" : {
"wkid" : 102100,
"latestWkid" : 3857
}
},
"queryFields" : [
{
"name" : "OBJECTID",
"type" : "esriFieldTypeInteger",
"alias" : "OBJECTID"
},
{
"name" : "SHAPE",
"type" : "esriFieldTypeGeometry",
"alias" : "SHAPE",
"geometryDef" : {
"avgNumPoints" : 0,
"geometryType" : "esriGeometryPolygon",
"hasM" : false,
"hasZ" : false,
"spatialReference" : {
"wkid" : 102100,
"latestWkid" : 3857
}
}
},
{
"name" : "GDB_GEOMATTR_DATA",
"type" : "esriFieldTypeBlob",
"alias" : "GDB_GEOMATTR_DATA"
}
],
"spatialStorageType" : 2
}
However I get an exception:
"Cannot cast Newtonsoft.Json.Linq.JArray to Newtonsoft.Json.Linq.JToken."
If I remove the queryFields element from the json, sqldataconn2.json (see attached), it runs without error.