I covered this Parsing JSON question using Json.net and it is close to what I need. Critical difference. I need to parse an array of x, y pairs that form one or more lines per record. Here is an example of my input
{
"displayFieldName" : "FACILITYID",
"fieldAliases" : {
"FACILITYID" : "Facility Identifier",
},
"geometryType" : "esriGeometryPolyline",
"spatialReference" : {
"wkid" : 4326
},
"features" : [
{
"attributes" : {
"FACILITYID" : "",
"OBJECTID" : 1,
},
"geometry" :
{
"paths" :
[
[
[-80.3538239379999, 27.386884271],
[-80.3538100319999, 27.3868901900001],
[-80.3538157239999, 27.3869008510001]
]
]
}
},
{
"attributes" : {
"FACILITYID" : "",
"OBJECTID" : 2,
},
"geometry" :
{
"paths" :
[
[
[-80.3538239379999, 27.386884271],
[-80.3538295849999, 27.3868948420001]
]
]
}
}
]
}
(Check out http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/WaterTemplate/WaterDistributionNetwork/MapServer/9/query?outFields= * & where = OBJECTID% 3C20 & f = pjson for a full list)
I need to parse arrays of ["features"] ["geometry"] ["paths"] in strings consisting of x, y pairs. This is how I get all the paths (one per record, as in an array of functions):
var allPaths = from p in jsonObject["features"].Children()["geometry"]
select p["paths"];
, :
foreach (var eachPolylineInPath in allPaths)
{
IEnumerable<Point> linePoints = from line in eachPolylineInPath.Children()
select new Point(
(double) line[0],
(double) line[1],
double.NaN);
}
, . JArray LINQ-y, JProperty .
, - JSON.NET LINQ , , , .