Hi
I hope someone smarter than me can point me in the right direction.
I'm trying to build an SDK Addin that lets users ZoomTo their location of interest, by choosing items from Picklists and a Listbox (States, Meridian, PLSS). Were using REST JSON requests to populate the lists and get the ZoomTo Extents and so on.
But parsing the JSON has been difficult, especially to "reach into" the JSON Results string, and extract specific branches out of JSON Query Results. Say like to get the "features" branch; or the "Polygon" branch; on in my current case the "MultiPolygon"\ "coordinates" branch.
I've been resorting to build my own custom parsing routines in C# -- but figure that there must be a "better" way. Quicker and easier ways would be good too.
Once the "coordinates" are extracted they are converted in to CIM Polygons that get displayed, with a Flashing effect, in a Graphics Layer. That's all working -- for the Extent value boxes anyways.
So my general question is this:
Example JSON Result:
"{\"type\":\"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:3857\"}},\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-13621951.758200001,5709599.9202999994],[-13621802.244800001,5709880.7739999965],[-13621740.0636,5710117.8229999989],[-13621702.693700001,5710191.0270999968],[-13621644.159600001,5710305.691399999],[-13621638.2338,5710374.6024999991],[-13621633.815499999,5710425.9847000018],[-13621682.2117,5710499.6832000017],[-13621705.7629,5710535.5474999994],[-13621993.3815,5710821.9514999986],[-13622324.5537,5711055.6231999993],[-13622461.691500001,5711116.7871999964],[-13622461.6733,5711028.2863000035],[-13622461.6666,5710969.5345999971],[-13622461.660399999,5710928.4465000033],[-13622463.6406,5710460.3496000022],[-13622463.622400001,5710300.120099999],[-13622463.562800001,5710035.1215000004],[-13622463.544599999,5709951.5729999989],[-13622463.4177,5709728.7648999989],[-13622463.3717,5709654.8347000033],[-13622463.344700001,5709611.3665999994],[-13622463.2466,5709453.7300999984],[-13622463.2465,5709450.0371999964],[-13622463.245000001,5709369.6709999964],[-13622463.244100001,5709322.6674000025],[-13622463.244100001,5709272.3350000009],[-13622463.3762,5709112.9482999966],[-13622463.5187,5708759.7960999981],[-13622463.907499999,5708185.126500003],[-13622463.442200001,5707616.7730000019],[-13622463.445,5707614.2694000006],[-13622463.5967,5707485.4663000032],[-13622463.7951,5707317.1313000023],[-13622464.043299999,5707106.547799997],[-13622464.120000001,5707041.5172000006],[-13622433.809500001,5706604.9717999995],[-13622423.4694,5706456.0539999977],[-13622416.049899999,5706234.1833000034],[-13622414.102400001,5706175.9469999969],[-13622411.1373,5705896.7626999989],[-13622411.9432,5705876.8407000005],[-13622414.9026,5705803.6841999963],[-13622415.360399999,5705792.366899997],[-13622415.523,5705788.3488999978],[-13622415.5788,5705786.9676999971],[-13622415.921700001,5705778.4919999987],[-13622415.9778,5705777.1048000008],[-13622416.0096,5705776.3169],[-13622416.0458,5705775.4218999967],[-13622416.070900001,5705774.8040999994],[-13622416.0956,5705774.1943000033],[-13622416.897599999,5705754.3667000011],[-13622417.530999999,5705738.7078000009],[-13622419.574900001,5705688.185999997],[-13622425.751400001,5705535.5028000027],[-13622434.295499999,5705324.3017999977],[-13622435.588399999,5705273.1155000031],[-13622436.4342,5705239.6283000037],[-13622439.6357,5705112.876500003],[-13622442.458900001,5705001.0998999998],[-13622443.3464,5704965.9635000005],[-13622452.7678,5704751.681400001],[-13622452.783300001,5704724.9593999982],[-13622453.6735,5704642.6358999982],[-13622454.8869,5704530.422799997],[-13622455.888700001,5704437.7752000019],[-13622456.316,5704398.2714999989],[-13622457.259399999,5704177.2960999981],[-13622457.882399999,5704121.4803000018],[-13622461.467700001,5703800.2113000005],[-13622463.707899999,5703599.4853999987],[-13622272.8409,5703598.4719000012],[-13622096.389899999,5703598.1484000012],[-13622067.0188,5703598.0945999995],[-13622011.3588,5703598.1709999964],[-13621998.011300001,5703598.1893000007],[-13621954.1588,5703598.249499999],[-13621926.9813,5703598.2867999971],[-13621905.943500001,5703598.315700002],[-13621894.6939,5703598.3312999979],[-13621332.864399999,5703600.8985999972],[-13620760.146499999,5703610.3681999967],[-13620187.431299999,5703619.8378999978],[-13619617.035700001,5703612.7318999991],[-13619046.6427,5703605.6221999973],[-13618473.790100001,5703603.0253999978],[-13617900.940000001,5703600.4324000031],[-13617328.896,5703598.860299997],[-13616756.854600001,5703597.2880999967],[-13616182.923799999,5703593.378200002],[-13615608.9954,5703589.4682999998],[-13615035.8785,5703587.4855000004],[-13614462.761500001,5703585.5028000027],[-13613890.1032,5703584.1045000032],[-13613317.4475,5703582.7101000026],[-13612746.15,5703580.442400001],[-13612174.8498,5703578.174999997],[-13611600.986400001,5703585.4954999983],[-13611027.1229,5703592.8158999979],[-13610454.1614,5703589.6199000031],[-13609881.202500001,5703586.4275999963],[-13609307.0513,5703582.9319999963],[-13608801.250300001,5703579.8489999995],[-13608732.897599999,5703579.432599999],[-13608731.3243,5704133.6661999971],[-13608729.751,5704687.9341999963],[-13608728.081900001,5705244.0495000035],[-13608726.672499999,5705770.1306999996],[-13608726.591600001,5705800.3473000005],[-13608728.7271,5706072.1565999985],[-13608729.5022,5706170.822300002],[-13608731.0418,5706366.4706000015],[-13608735.489399999,5706932.6335999966],[-13608737.561000001,5707083.9239000008],[-13608738.239700001,5707133.4919999987],[-13608740.2963,5707283.6982999966],[-13608742.1094,5707416.123800002],[-13608743.2106,5707496.5489000008],[-13608743.3298,5707566.5666999966],[-13608900.269400001,5707584.8558000028],[-13608986.2414,5707509.1794999987],[-13608937.864399999,5707405.4786000028],[-13608937.876600001,5707382.8916999996],[-13608937.911,5707319.5159000009],[-13608979.107000001,5707243.5331000015],[-13609033.1359,5707143.8816],[-13609315.811900001,5707057.2480999976],[-13609334.1492,5707051.6305999979],[-13609894.153999999,5707021.2049999982],[-13610109.552999999,5707009.4927999973],[-13610311.033199999,5707057.1133000031],[-13610364.1284,5707069.6626000032],[-13610472.4132,5707095.2562000006],[-13610487.690299999,5707098.8662],[-13610644.427200001,5707135.9030999988],[-13610858.208900001,5707222.5116000026],[-13610926.9463,5707143.9175999984],[-13610948.4189,5707119.3659000024],[-13610952.371100001,5707114.8470000029],[-13611002.6624,5707126.7087000012],[-13611050.2267,5707137.9272999987],[-13611544.0276,5707251.2765000015],[-13611630.4169,5707347.1041999981],[-13611650.039900001,5707368.8752999976],[-13611845.847100001,5707277.7025000006],[-13612215.2699,5707249.2965999991],[-13612801.338399999,5707204.197300002],[-13612925.1853,5707194.6608999968],[-13613098.0933,5707273.4171999991],[-13613384.9421,5707215.2324000001],[-13613616.204,5707131.0476000011],[-13613626.4904,5707127.3030999973],[-13613640.533399999,5707129.1758999974],[-13613742.8389,5707142.8194999993],[-13613896.134500001,5707107.4606999978],[-13613923.8518,5707099.0383000001],[-13614407.588500001,5706952.0055999979],[-13614463.4483,5706944.2048999965],[-13614588.821699999,5706926.6942000017],[-13615051.826099999,5706904.6542000026],[-13615171.010200001,5706898.9703999981],[-13615641.248599999,5706773.8621999994],[-13616205.8202,5706702.9549999982],[-13616314.2019,5706689.3387999982],[-13616769.637600001,5706736.4880999997],[-13617333.457699999,5706794.8213],[-13617431.2433,5706804.9345000014],[-13617897.215399999,5706863.4346999973],[-13617944.965300001,5706872.7229999974],[-13617945.752999999,5706873.6383000016],[-13618043.7806,5706987.5367999971],[-13618086.273499999,5707036.9099000022],[-13618087.6108,5707038.0829999968],[-13618088.9482,5707039.256099999],[-13618162.1372,5707103.3363000005],[-13618227.833000001,5707160.8561000004],[-13618452.9826,5707435.4761999995],[-13618551.2612,5707555.3407000005],[-13618611.137800001,5707628.3693000004],[-13618854.2775,5707874.4997000024],[-13619016.077,5707993.3835000023],[-13619277.3104,5708185.3189999983],[-13619863.285799999,5708718.4706000015],[-13620140.495299999,5708970.701700002],[-13620427.134100001,5709228.2066000029],[-13620474.0156,5709270.3214000016],[-13620503.0756,5709314.635300003],[-13620572.851,5709421.0229000002],[-13620592.253600001,5709450.6064999998],[-13620628.071800001,5709505.2203999981],[-13620693.4407,5709604.8929999992],[-13620701.2368,5709616.7801999971],[-13620932.4737,5709969.3726999983],[-13620994.170699999,5710063.4510999992],[-13621115.563000001,5710202.8574000001],[-13621179.9893,5710276.8458999991],[-13621252.768199999,5710360.4275000021],[-13621287.115499999,5710387.8068000004],[-13621333.6368,5710424.8813999966],[-13621410.5943,5710360.1017000005],[-13621447.712200001,5710288.6035000011],[-13621477.353599999,5710244.6855999976],[-13621708.0875,5709902.8275000006],[-13621813.6514,5709746.4270000011],[-13621875.254999999,5709655.1582999974],[-13621895.187100001,5709625.6221999973],[-13621900.154899999,5709618.2607000023],[-13621957.652800001,5709588.8479000032],[-13621951.758200001,5709599.9202999994]]],[[[-13618898.4924,5708648.2163000032],[-13618909.8749,5708684.0816999972],[-13618928.3654,5708733.5982000008],[-13618952.5122,5708778.1533999965],[-13619013.652800001,5708822.2991999984],[-13619063.4749,5708866.3505999967],[-13619080.503600001,5708909.4178000018],[-13619107.449200001,5708949.704400003],[-13619134.4745,5709002.1538000032],[-13619184.314399999,5709076.9706000015],[-13619248.267200001,5709148.3258000016],[-13619272.4922,5709183.5825999975],[-13619310.774599999,5709243.9958000034],[-13619350.644099999,5709306.5688000023],[-13619379.0746,5709361.8937999979],[-13619426.054499999,5709405.2075000033],[-13619438.8003,5709438.2233999968],[-13619454.4047,5709470.5478999987],[-13619499.9287,5709506.6953999996],[-13619563.9329,5709572.3290999979],[-13619595.2455,5709646.2811999992],[-13619627.8927,5709709.512000002],[-13619666.4022,5709753.4724000022],[-13619706.146499999,5709788.1410999969],[-13619730.340300001,5709827.6921999976],[-13619757.369899999,5709869.4120000005],[-13619814.3357,5709902.0751999989],[-13619901.0714,5709946.4290999994],[-13620027.6906,5709997.5460999981],[-13620121.5558,5710053.4042000026],[-13620191.342900001,5710110.4981999993],[-13620232.574999999,5710138.0226999968],[-13620317.8884,5710182.3614000008],[-13620323.648400001,5710142.3379999995],[-13620313.7072,5710103.6187999994],[-13620289.5077,5710053.3350000009],[-13620268.217599999,5710018.1022000015],[-13620255.3994,5709949.3082000017],[-13620192.2214,5709846.4770999998],[-13620144.4475,5709768.0989999995],[-13620086.120000001,5709661.014700003],[-13620049.214,5709594.8897999972],[-13620005.117600001,5709525.128899999],[-13619936.8596,5709400.7951999977],[-13619851.5507,5709279.9007999972],[-13619774.7072,5709192.7023999989],[-13619716.422800001,5709114.241899997],[-13619672.3759,5709060.9387999997],[-13619626.866599999,5709001.1845000014],[-13619558.564100001,5708905.4725999981],[-13619474.689100001,5708806.7712000012],[-13619376.5492,5708741.5782999992],[-13619294.051899999,5708692.9681999981],[-13619232.8039,5708650.9704999998],[-13619167.470100001,5708618.2392000034],[-13619116.1907,5708599.932099998],[-13619057.894200001,5708578.7053999975],[-13619012.346799999,5708589.7765000015],[-13618988.1262,5708619.6237000003],[-13618969.672600001,5708630.9182000011],[-13618948.245900001,5708624.3025999963],[-13618935.458700001,5708618.4737000018],[-13618919.908399999,5708612.6218999997],[-13618905.566500001,5708622.5195000023],[-13618898.4924,5708648.2163000032]]],[[[-13618918.465700001,5708462.3747000024],[-13618968.291000001,5708451.3391999975],[-13618999.6315,5708444.4438999966],[-13619065.0855,5708451.4218000025],[-13619107.797899999,5708438.1807999983],[-13619110.592900001,5708412.450000003],[-13619104.9341,5708395.9488999993],[-13619082.2256,5708349.9768999964],[-13618975.506299999,5708223.1889000013],[-13618968.607799999,5708216.693400003],[-13618830.486299999,5708093.939199999],[-13618674.1085,5708002.5086999983],[-13618497.723099999,5707905.9029000029],[-13618349.7719,5707852.4525000006],[-13618105.0592,5707785.317400001],[-13618022.5836,5707746.7145000026],[-13617932.9618,5707688.7383999974],[-13617906.726,5707671.3505000025],[-13617860.4572,5707640.9196999967],[-13617790.817,5707580.9633999988],[-13617719.717,5707503.8268000036],[-13617661.377900001,5707456.8409999982],[-13617627.284299999,5707420.0733999982],[-13617625.864399999,5707408.6168000028],[-13617652.9551,5707398.1146000028],[-13617722.6118,5707413.0053000003],[-13617799.4274,5707445.8386000022],[-13617883.360399999,5707480.1612000018],[-13617906.4881,5707485.3628000021],[-13617958.7809,5707498.675999999],[-13618017.025800001,5707514.1845000014],[-13618059.7477,5707531.7092999965],[-13618069.6392,5707531.7920000032],[-13618069.715599999,5707468.8435999975],[-13618022.782099999,5707432.6851999983],[-13617963.134500001,5707349.9252000004],[-13617906.1084,5707295.0851000026],[-13617896.2048,5707285.7030000016],[-13617837.901999999,5707255.887500003],[-13617775.340399999,5707213.1599999964],[-13617702.888599999,5707148.8915000036],[-13617601.831500001,5707127.2995000035],[-13617422.655400001,5707101.4717999995],[-13617267.591800001,5707101.5952999964],[-13617173.637499999,5707125.8373000026],[-13617113.993900001,5707118.1811000034],[-13617052.787900001,5707105.5033000037],[-13617027.158300001,5707122.4532999992],[-13617005.741,5707189.5099000037],[-13616977.339299999,5707239.3405999988],[-13616938.815200001,5707274.0639000013],[-13616917.457800001,5707333.9693000019],[-13616927.4396,5707376.2568999976],[-13616943.0536,5707416.4475999996],[-13616977.1764,5707428.1811999977],[-13617021.255199999,5707400.6569000036],[-13617045.5031,5707367.9583000019],[-13617055.4684,5707337.9992000014],[-13617055.487500001,5707325.123999998],[-13617068.312100001,5707283.743900001],[-13617091.035399999,5707283.936499998],[-13617138.0089,5707293.6327000037],[-13617177.816199999,5707318.2894999981],[-13617216.239799999,5707337.9274000004],[-13617277.332,5707385.6534999982],[-13617396.7861,5707466.7773000002],[-13617637.0492,5707659.7908999994],[-13617763.621399999,5707775.3082000017],[-13617867.4309,5707852.7195999995],[-13617907.0822,5707864.4974000007],[-13617957.0418,5707879.9373999983],[-13618033.891100001,5707877.0036000013],[-13618109.279899999,5707899.8090000004],[-13618170.380899999,5707958.2625999972],[-13618227.3179,5708013.8198999986],[-13618278.456799999,5708070.0451000035],[-13618350.975400001,5708170.8011000007],[-13618406.809500001,5708219.9107000008],[-13618439.1983,5708248.0797000006],[-13618524.5485,5708273.8272999972],[-13618621.247099999,5708285.3605000004],[-13618715.142900001,5708312.6067999974],[-13618796.1656,5708355.4849999994],[-13618848.8662,5708406.7136999965],[-13618918.465700001,5708462.3747000024]]]]},\"properties\":{\"SRVNAME\":null}}]}"
(that example has 3 separate Polygon "rings" that are delimited with the Purple text [[[ ... ]]] )
Solved! Go to Solution.
This is how i usually do it:
var json = /// this is your json string
var parsedJson = JsonConvert.DeserializeObject<Rootobject>(json);
MessageBox.Show($@"parsed json: features {parsedJson.features.Length}");
Here is the auto generated class model that represents your JSON:
public class Rootobject
{
public string type { get; set; }
public Crs crs { get; set; }
public Feature[] features { get; set; }
}
public class Crs
{
public string type { get; set; }
public Properties properties { get; set; }
}
public class Properties
{
public string name { get; set; }
}
public class Feature
{
public string type { get; set; }
public Geometry geometry { get; set; }
public Properties1 properties { get; set; }
}
public class Geometry
{
public string type { get; set; }
public float[][][][] coordinates { get; set; }
}
public class Properties1
{
public object SRVNAME { get; set; }
}
Also because of the unfortunate naming used in your JSON you will get some naming conflicts like for example for 'Geometry', 'Feature' etc. which also exist in the Pro SDK namespace.
To get an Pro Geometry you have loop through the coordinates to get your 'rings', and for each 'ring' the coordinate collection:
public float[][][][] coordinates
Use Polygon Builder to create you polygon and add each 'ring' as a Part: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic8490.html ... use a List<Coordinate2D> to add each 'ring' as a part to your polygon.
This is how i usually do it:
var json = /// this is your json string
var parsedJson = JsonConvert.DeserializeObject<Rootobject>(json);
MessageBox.Show($@"parsed json: features {parsedJson.features.Length}");
Here is the auto generated class model that represents your JSON:
public class Rootobject
{
public string type { get; set; }
public Crs crs { get; set; }
public Feature[] features { get; set; }
}
public class Crs
{
public string type { get; set; }
public Properties properties { get; set; }
}
public class Properties
{
public string name { get; set; }
}
public class Feature
{
public string type { get; set; }
public Geometry geometry { get; set; }
public Properties1 properties { get; set; }
}
public class Geometry
{
public string type { get; set; }
public float[][][][] coordinates { get; set; }
}
public class Properties1
{
public object SRVNAME { get; set; }
}
Also because of the unfortunate naming used in your JSON you will get some naming conflicts like for example for 'Geometry', 'Feature' etc. which also exist in the Pro SDK namespace.
To get an Pro Geometry you have loop through the coordinates to get your 'rings', and for each 'ring' the coordinate collection:
public float[][][][] coordinates
Use Polygon Builder to create you polygon and add each 'ring' as a Part: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic8490.html ... use a List<Coordinate2D> to add each 'ring' as a part to your polygon.
Thank you Wolf for the interesting solution.
I will try that custom class implementation, see if I can get it working.
A couple of quick questions:
1) Will this class, once built, be flexible enough to support MultiplePolygons, that have different numbers of Polygon rings? Not all the JSON results will have just 3 rings, as shown in the sample. That number will vary case by case.
2) Is Newton.JSON commonly used/recommended library used by ESRI to handle JSON? I've been trying to use just Microsoft libraries, since Newtonsoft is a 3rd party vendor.
Thanks again for you detailed response.
James Siebert
Hi Wolf -
I notice the .NET SDK for runtime provides classes that hide Json deserialization details, as shown in the sample at the bottom of this page.
Are there any problems in using assemblies from runtime SDK in Arc Pro extensions?
For example, it seems like one could write .ToCIM() extension methods for runtime SDK classes.
Thanks, Kirk
I would suggest to used the ArcGIS Pro SDK instead: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring#create-featurelayer-with-a-quer...
Just replace the URI with your online service path.
FYI
Implementing that custom Json Class was pretty straight-forward using that paste special "from json" trick. So thanks for that.
And it is relatively easy to access and read the various Json "tag" values too once that Class Object gets instantiated. Example:
--- ---
var jsonPoly = responseStringPolygon;
var parsedJson = JsonConvert.DeserializeObject<Rootobject>(jsonPoly);
float[][][] parsedRings = parsedJson.features[0].geometry.rings;
--- ---
Regarding getting those Coordinates back out of Class Object, and into a List of Coordinates (to created my Graphic Layer Symbols of the user selections) -- I've built out some nested for loops to extract out the individual Polygon rings -- from the n-Dimensional array of float[][][] parsedRings as follows:
--- ---
float[][][] parsedRings = parsedJson2.features[0].geometry.rings;
int RingCount = 0;
RingCount = parsedRings.Length;
ArcGIS.Core.Geometry.SpatialReference geoWkid = spatRef;
for (int j = 0; j <= RingCount - 1; j++)
{
List<Coordinate2D> ListCoors = new List<Coordinate2D>();
int RingVertCount = 0;
RingVertCount = parsedRings[j].Length;
for (int k = 0; k <= RingVertCount - 1; k++)
{
ListCoors.Add(new Coordinate2D(parsedRings[j][k][0], parsedRings[j][k][1]));
}
ArcGIS.Core.Geometry.Polygon PLSSPoly = PolygonBuilder.CreatePolygon(ListCoors, geoWkid);
// ... do other stuff with the Polygon rings
// build each Polygon Symbol and flash them in the Graphics Layer, using the PLSSPoly Polygon
}
[for anyone else trying to implement this solution.]
--- ---
That loop works fine, and is very fast to build out and display -- for a single Polygon ring.
However the performance drops off, the more "parts" the original Township PLSS polygon has (as in the case of lakes and rivers in a location).
As currently implemented, each sub ring is being processed into the Graphics Layer, one at a time, which takes time, the more complex the stack of rings is, in the source json for the chosen Township.
I am hoping that it possible to "stack up" all the ring pieces into a single List<Coordinate2D> ListCoors that would be accepted by the PolygonBuilder.CreatePolygon() method.
I was able to "stack up" all the ring pieces into a single 'fabricated' Json string with a single "rings" tag previously. And the PolygonBuilder.FromJson() method accepted it, and processed the entire stack of rings, all as a bundle, all at once. It was quite fast. But likely not as reliable or robust as using a Json Class Object, given the vagaries and nuances of Json responses, over a large dataset.
Anyways thanks for pointers on this task, I much prefer the Json Class approach, to the Json String parsing approach. Assuming I can figure out how to get the performance up to par.
I'm thinking right now an Array of List<Coordinate2D> might do the trick. Assuming PolygonBuilder.CreatePolygon() can handle it.
Thanks again
James Siebert
Wolf, seems like a good solution - although I found it doesn't seem to work that well when you want attribute fields brought back. The JSON returned explicitly creates a field the same as the out-field name when it's converted to a C# class - so your code becomes very tethered to the feature-service you are querying and the naming of it's fields - it's very unlikely your fields of interest will be called the same name especially over many different feature services - resulting in limited use for this class.
Have you any ideas how you can get round this?
To parse JSON returned by a service with a variable schema you would need to be able to retrieve schema definition to make sense of it. This means that you would need to know what constitutes a coordinate (x/y field names, or x/y/z, or long/lat or geometry type) , you would also need to know which fields are attributes and what type are those attribute fields are (date, number, string, ...). An example for this would be the ArcGIS Rest API. When you query an ArcGIS Rest API's feature service the JSON response would look like this:
{
"objectIdFieldName": "<objectIdFieldName>",
"globalIdFieldName": "<globalIdFieldName>",
"geometryType": "<geometryType>", //for feature layers only
"spatialReference": <spatialReference>, //for feature layers only
"hasZ": <true|false>, //added in 10.1
"hasM": <true|false>, //added in 10.1
"fields": [
{"name": "<fieldName1>", "type" : "<fieldType1>", "alias" : "<fieldAlias1>", "length" : "<length1>"},
{"name": "<fieldName2>", "type" : "<fieldType2>", "alias" : "<fieldAlias2>", "length" : "<length2>"}
],
"features": [ //features will include geometry for feature layers only
<feature1>, <feature2>
]
}
You can see from this example that the schema proceeds the actual feature data stored in the 'features' array. The first part of the JSON response is not variable and allows you to extract attribute column names and types. In order to parse this type of JSON and then process it you can utilize the C# dynamic type with Newtonsoft (aka Json.Net) as shown here: Querying JSON with dynamic (newtonsoft.com)
Since your schema definition (the first part of the JSON response) has a known definition, as for example the fields array, you can now query all features and their attribute values, regardless of the column names coming back in a JSON response.
As far as Newton.JSON see this Pro SDK requirement: third-party-assemblies ... the Nuget has 800 million downloads, so it's commonly used (including by ArcGIS Pro).
As far as multiple polygon rings, you can see that your coordinates are stored in a multi dimensional array so it should handle any number of parts. The length of the first dimension holds your number of rings.
Thanks again Wolf,
Appreciate the answers and the cool solution.
James