Read JSON file into a Jarray and access data dynamically
<p>I am trying to read in a json file which is very complex into a JArray that can be accessed dynamically in a foreach statement. However I am getting an error which is stating 'Current JsonReader item is not an Array' I am able to access the keys and values if I use a JObject but that is not what I need I need to be able to go through the records and search by names or IDs, etc. I am a bit new at newtwonsoft and JSON.net so any help would be appreciated!</p>

<pre><code>JArray o1 = JArray.Parse(File.ReadAllText(@"myfilepath"));

dynamic records = o1;

foreach (dynamic record in records)
{
       Console.WriteLine(record.Id + " (" + record.Name + ")");
}
</code></pre>

<p>My json file looks like this, there are multiple records however I have shortened it.  I need to access and search by Id or Name however I am having issues accessing.</p>

<pre><code>String json = @"{
  "RecordSetBundles" : [ {
    "Records" : [ {
      "attributes" : {
        "type" : "nihrm__Location__c",
        "url" : "/services/data/v38.0/sobjects/nihrm__Location__c/a0di0000001nI3oAAE"
      },
      "CurrencyIsoCode" : "USD",
      "Id" : "a0di0000001nI3oAAE",
      "Name" : "The City Hotel",
      "nihrm__Abbreviation__c" : "TCH",
      "nihrm__AddressLine1__c" : "1 Main Street",
      "nihrm__AlternateNameES__c" : "El Ciudad Hotel",
      "nihrm__AvailabilityScreenView__c" : "Combined",
      "nihrm__Geolocation__c" : null,
      "nihrm__HideBookingsFromPortal__c" : false,
      "nihrm__IsActive__c" : true,
      "nihrm__IsPlannerPortalEnabled__c" : false,
      "nihrm__isRemoveCancelledEventsFromBEOs__c" : false,
      "nihrm__ManagementAffliation__c" : "NI International",
      "nihrm__NearestAirportCode__c" : "MHT",
      "nihrm__Phone__c" : "(207) 555-5555",
      "nihrm__PostalCode__c" : "04103",
      "nihrm__PropertyCode__c" : "TCH",
      "nihrm__RegionName__c" : "Northeast",
      "nihrm__RestrictBookingMoveWithPickup__c" : true,
      "nihrm__RohAllowedStatuses__c" : "Prospect;Tentative;Definite",
      "nihrm__StateProvince__c" : "ME",
      "nihrm__SystemOfMeasurement__c" : "Standard",
      "nihrm__TimeZone__c" : "GMT-05:00 Eastern Daylight Time (America/New_York)",
      "nihrm__UpdateBookingEventAverageChecks__c" : false,
      "nihrm__UseAlternateLanguage__c" : false,
      "nihrm__Website__c" : "www.thecityhotelweb.com"
    } ],
    "ObjectType" : "nihrm__Location__c",
    "DeleteFirst" : false
  },
</code></pre>

<p>Here is a link to the entire json:
<a href="https://codeshare.io/rGL6K5" rel="nofollow noreferrer">https://codeshare.io/rGL6K5</a></p>