JSON:
"divisions": {
"ocd-division/country:us": {
"name": "United States",
"officeIndices": [
0,
1
]
},
"ocd-division/country:us/state:mo": {
"name": "Missouri",
"officeIndices": [
2,
11,
12
]
},
"ocd-division/country:us/state:mo/cd:6": {
"name": "Missouri's 6th congressional district",
"officeIndices": [
3
]
},
Я пытаюсь вытащить Missouri's 6th congressional district
из вышеприведенного JSON. Я могу вытащить его с помощью следующего кода:
Console.WriteLine(json.SelectToken("divisions").
SelectToken("ocd-division/country:us/state:mo/cd:6").SelectToken("name").ToString)
Это работает просто отлично, но, как вы увидите, ocd-division/country:us/state:mo/cd:6
не будет таким же для других штатов или даже других частей штата. Мне интересно, почему это не помогает решить проблему ...
Console.WriteLine(json.SelectToken("divisions").
SelectToken("ocd-division/country:us").Next.Next.SelectToken("name").ToString)
Я рассчитывал, так как все состояния будут в us
Я мог бы начать там, а затем пойти двумя братьями и сестрами вперед, чтобы добраться до Missouri's 6th congressional district
.
ПОЛНЫЙ JSON:
{
"kind": "civicinfo#representativeInfoResponse",
"normalizedInput": {
"line1": "****** *** ***",
"city": "******",
"state": "**",
"zip": "*****"
},
"divisions": {
"ocd-division/country:us": {
"name": "United States",
"officeIndices": [
0,
1
]
},
"ocd-division/country:us/state:mo": {
"name": "Missouri",
"officeIndices": [
2,
4,
5,
8,
9,
10,
11,
12
]
},
"ocd-division/country:us/state:mo/cd:6": {
"name": "Missouri's 6th congressional district",
"officeIndices": [
3
]
},
"ocd-division/country:us/state:mo/county:clay": {
"name": "Clay County",
"officeIndices": [
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
]
},
"ocd-division/country:us/state:mo/place:kearney": {
"name": "Kearney city"
},
"ocd-division/country:us/state:mo/sldl:38": {
"name": "Missouri State House district 38",
"officeIndices": [
7
]
},
"ocd-division/country:us/state:mo/sldu:12": {
"name": "Missouri State Senate district 12",
"officeIndices": [
6
]
}
},
"offices": [
{
"name": "President of the United States",
"divisionId": "ocd-division/country:us",
"levels": [
"country"
],
"roles": [
"headOfState",
"headOfGovernment"
],
"officialIndices": [
0
]
},
{
"name": "Vice-President of the United States",
"divisionId": "ocd-division/country:us",
"levels": [
"country"
],
"roles": [
"deputyHeadOfGovernment"
],
"officialIndices": [
1
]
},
{
"name": "United States Senate",
"divisionId": "ocd-division/country:us/state:mo",
"levels": [
"country"
],
"roles": [
"legislatorUpperBody"
],
"officialIndices": [
2,
3
]
},
{
"name": "United States House of Representatives MO-06",
"divisionId": "ocd-division/country:us/state:mo/cd:6",
"levels": [
"country"
],
"roles": [
"legislatorLowerBody"
],
"officialIndices": [
4
]
},
{
"name": "Governor",
"divisionId": "ocd-division/country:us/state:mo",
"levels": [
"administrativeArea1"
],
"roles": [
"headOfGovernment"
],
"officialIndices": [
5
]
},
{
"name": "Lieutenant Governor",
"divisionId": "ocd-division/country:us/state:mo",
"levels": [
"administrativeArea1"
],
"roles": [
"deputyHeadOfGovernment"
],
"officialIndices": [
6
]
},
{
"name": "MO State Senate District 12",
"divisionId": "ocd-division/country:us/state:mo/sldu:12",
"levels": [
"administrativeArea1"
],
"roles": [
"legislatorUpperBody"
],
"officialIndices": [
7
]
},
{
"name": "MO State House District 38",
"divisionId": "ocd-division/country:us/state:mo/sldl:38",
"levels": [
"administrativeArea1"
],
"roles": [
"legislatorLowerBody"
],
"officialIndices": [
8
]
},
{
"name": "State Supreme Court Judge",
"divisionId": "ocd-division/country:us/state:mo",
"officialIndices": [
9,
10,
11,
12,
13,
14,
15
]
},
{
"name": "State Treasurer",
"divisionId": "ocd-division/country:us/state:mo",
"officialIndices": [
16
]
},
{
"name": "Attorney General",
"divisionId": "ocd-division/country:us/state:mo",
"officialIndices": [
17
]
},
{
"name": "State Auditor",
"divisionId": "ocd-division/country:us/state:mo",
"officialIndices": [
18
]
},
{
"name": "Secretary of State",
"divisionId": "ocd-division/country:us/state:mo",
"officialIndices": [
19
]
},
{
"name": "Assessor",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
20
]
},
{
"name": "Treasurer",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
21
]
},
{
"name": "Circuit Clerk",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
22
]
},
{
"name": "Auditor",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
23
]
},
{
"name": "County Commissioner Chairman",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
24
]
},
{
"name": "County Clerk",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
25
]
},
{
"name": "Collector",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
26
]
},
{
"name": "Prosecuting Attorney",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
27
]
},
{
"name": "Sheriff",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
28
]
},
{
"name": "Recorder",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
29
]
},
{
"name": "Public Administrator",
"divisionId": "ocd-division/country:us/state:mo/county:clay",
"officialIndices": [
30
]
}
],
"officials": [
{
"name": "Donald J. Trump",
"address": [
{
"line1": "The White House",
"line2": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"zip": "20500"
}
],
"party": "Republican Party",
"phones": [
"(202) 456-1111"
],
"urls": [
"http://www.whitehouse.gov/"
],
"photoUrl": "https://www.whitehouse.gov/sites/whitehouse.gov/files/images/45/PE%20Color.jpg",
"channels": [
{
"type": "GooglePlus",
"id": "+whitehouse"
},
{
"type": "Facebook",
"id": "whitehouse"
},
{
"type": "Twitter",
"id": "potus"
},
{
"type": "YouTube",
"id": "whitehouse"
}
]
},
{
"name": "Mike Pence",
"address": [
{
"line1": "The White House",
"line2": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"zip": "20500"
}
],
"party": "Republican Party",
"phones": [
"(202) 456-1111"
],
"urls": [
"http://www.whitehouse.gov/"
],
"photoUrl": "https://www.whitehouse.gov/sites/whitehouse.gov/files/images/45/VPE%20Color.jpg",
"channels": [
{
"type": "GooglePlus",
"id": "+whitehouse"
},
{
"type": "Facebook",
"id": "whitehouse"
},
{
"type": "Twitter",
"id": "VP"
}
]
},
{
"name": "Roy Blunt",
"address": [
{
"line1": "260 Russell Senate Office Building",
"city": "Washington",
"state": "DC",
"zip": "20510"
}
],
"party": "Republican Party",
"phones": [
"(202) 224-5721"
],
"urls": [
"http://www.blunt.senate.gov/"
],
"photoUrl": "http://bioguide.congress.gov/bioguide/photo/B/B000575.jpg",
"channels": [
{
"type": "Facebook",
"id": "SenatorBlunt"
},
{
"type": "Twitter",
"id": "RoyBlunt"
},
{
"type": "YouTube",
"id": "SenatorBlunt"
},
{
"type": "YouTube",
"id": "BluntforSenate2010"
}
]
},
{
"name": "Josh Hawley",
"address": [
{
"line1": "B40A Dirksen Senate Office Building",
"city": "Washington",
"state": "DC",
"zip": "20510"
}
],
"party": "Republican Party",
"phones": [
"(202) 224-6154"
],
"emails": [
"senator@hawley.senate.gov"
],
"channels": [
{
"type": "Twitter",
"id": "SenHawleyPress"
}
]
},
{
"name": "Sam Graves",
"address": [
{
"line1": "1135 Longworth House Office Building",
"city": "Washington",
"state": "DC",
"zip": "20515"
}
],
"party": "Republican Party",
"phones": [
"(202) 225-7041"
],
"urls": [
"http://graves.house.gov/"
],
"photoUrl": "https://graves.house.gov/sites/graves.house.gov/files/documents/Rep_Graves_Photo.JPG",
"channels": [
{
"type": "Facebook",
"id": "118514606128"
},
{
"type": "Twitter",
"id": "repsamgraves"
}
]
},
{
"name": "Mike Parson",
"address": [
{
"line1": "P.O. Box 720",
"city": "Jefferson City",
"state": "MO",
"zip": "65102"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-3222"
],
"urls": [
"https://governor.mo.gov/"
],
"photoUrl": "https://ltgov.mo.gov/wp-content/uploads/2017/01/Parson-headshot.jpg",
"emails": [
"ltgovinfo@ltgov.mo.gov"
],
"channels": [
{
"type": "Twitter",
"id": "GovParsonMO"
}
]
},
{
"name": "Mike Kehoe",
"address": [
{
"line1": "201 W. Capital Avenue",
"line2": "Room 224",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-4727"
],
"urls": [
"https://ltgov.mo.gov/"
],
"channels": [
{
"type": "Twitter",
"id": "LtGovMikeKehoe"
}
]
},
{
"name": "Dan Hegeman",
"address": [
{
"line1": "201 W CAPITOL AVE RM 332",
"line2": "JEFFERSON CTY",
"city": "",
"state": "MO",
"zip": "65101"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-1415"
],
"urls": [
"http://www.senate.mo.gov/mem12"
],
"photoUrl": "http://www.senate.mo.gov/17web/wp-content/uploads/2015/11/Hegeman-200x300.jpg",
"emails": [
"Dan.Hegeman@senate.mo.gov"
]
},
{
"name": "Doug Richey",
"address": [
{
"line1": "201 W CAPITOL AVE 116 A-1",
"line2": "JEFFERSON CTY",
"city": "",
"state": "MO",
"zip": "65101"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-2238"
],
"urls": [
"http://www.house.mo.gov/MemberDetails.aspx?district=38"
],
"emails": [
"Doug.Richey@house.mo.gov"
]
},
{
"name": "Patricia Breckenridge",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=499"
]
},
{
"name": "W. Brent Powell",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=113629"
]
},
{
"name": "Mary R. Russell",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=203"
]
},
{
"name": "George W. Draper, III",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=50536"
]
},
{
"name": "Paul C. Wilson",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=59001"
]
},
{
"name": "Zel M. Fischer",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=27084"
]
},
{
"name": "Laura Denvir Stith",
"address": [
{
"line1": "Missouri Supreme Court",
"line2": "207 West High Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Nonpartisan",
"phones": [
"(573) 751-4144"
],
"urls": [
"https://www.courts.mo.gov/page.jsp?id=183"
]
},
{
"name": "Scott Fitzpatrick",
"address": [
{
"line1": "P.O. Box 210",
"city": "Jefferson City",
"state": "MO",
"zip": "65102"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-8533"
],
"urls": [
"https://www.treasurer.mo.gov/"
],
"emails": [
"info@treasurer.mo.gov"
],
"channels": [
{
"type": "Twitter",
"id": "MOTreasurer"
}
]
},
{
"name": "Eric Schmitt",
"address": [
{
"line1": "207 W. High Street",
"line2": "P.O. Box 899",
"city": "Jefferson City",
"state": "MO",
"zip": "65102"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-3321"
],
"urls": [
"https://www.ago.mo.gov/"
],
"channels": [
{
"type": "Twitter",
"id": "AGEricSchmitt"
}
]
},
{
"name": "Nicole Galloway",
"address": [
{
"line1": "P.O. Box 869",
"city": "Jefferson City",
"state": "MO",
"zip": "65102"
}
],
"party": "Democratic Party",
"phones": [
"(800) 347-8597"
],
"urls": [
"https://auditor.mo.gov/"
],
"emails": [
"moaudit@auditor.mo.gov"
],
"channels": [
{
"type": "Twitter",
"id": "AuditorGalloway"
}
]
},
{
"name": "John (Jay) Ashcroft",
"address": [
{
"line1": "600 West Main Street,",
"city": "Jefferson City",
"state": "MO",
"zip": "65101"
}
],
"party": "Republican Party",
"phones": [
"(573) 751-4936"
],
"urls": [
"https://www.sos.mo.gov/"
],
"emails": [
"info@sos.mo.gov"
],
"channels": [
{
"type": "Twitter",
"id": "MissouriSOS"
}
]
},
{
"name": "Cathy Rinehart",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Democratic Party",
"phones": [
"(816) 407-3500"
],
"urls": [
"https://www.claycountymo.gov/departments/assessor"
],
"emails": [
"assessor@claycountymo.gov"
]
},
{
"name": "Ted Graves",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3540"
],
"urls": [
"https://www.claycountymo.gov/departments/treasurer"
],
"emails": [
"treasurer@claycountymo.gov"
]
},
{
"name": "Lee Bucksath",
"address": [
{
"line1": "11 South Water Street",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Unknown",
"phones": [
"(816) 407-3900"
],
"urls": [
"http://www.circuit7.net/circuitclerk/"
]
},
{
"name": "Victor S. Hurlbert",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3590"
],
"urls": [
"https://www.claycountymo.gov/departments/auditor"
],
"emails": [
"auditor@claycountymo.gov"
]
},
{
"name": "Jerry Nolte",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3600"
],
"urls": [
"https://www.claycountymo.gov/departments/boards-commissions"
],
"emails": [
"commission@claycountymo.gov"
]
},
{
"name": "Megan Thompson",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3570"
],
"urls": [
"https://www.claycountymo.gov/departments/county-clerk"
],
"emails": [
"clerk@claycountymo.gov"
]
},
{
"name": "Lydia McEvoy",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3200"
],
"emails": [
"collector@claycountymo.gov"
]
},
{
"name": "Dan White",
"address": [
{
"line1": "11 S Water Street",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Democratic Party",
"phones": [
"(816) 736-8300"
],
"urls": [
"http://www.circuit7.net/prosatty/"
],
"emails": [
"jim_roberts@claycopa.com"
]
},
{
"name": "Paul Vescovo, III",
"address": [
{
"line1": "12 S. Water St.",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3750"
],
"urls": [
"http://www.claymosheriff.org/index.html"
],
"emails": [
"sheriff@sheriffclayco.com"
]
},
{
"name": "Katee Porter",
"address": [
{
"line1": "1 Courthouse Square",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3550"
],
"urls": [
"https://www.claycountymo.gov/departments/recorder-deeds"
],
"emails": [
"recorder@claycountymo.gov"
]
},
{
"name": "Sarah Mills",
"address": [
{
"line1": "11 S Water Street",
"city": "Liberty",
"state": "MO",
"zip": "64068"
}
],
"party": "Republican Party",
"phones": [
"(816) 407-3250"
],
"urls": [
"http://www.claycomopa.com/"
],
"emails": [
"ccadmin@claycountymo.gov"
]
}
]
}