Are you asking for the C# structure to back the JSON you gave? Each curly brace represents a JSON object which maps to a C# class. Square brackets are arrays in JSON so they map to either an array or IEnumerable<T>
in C#. Everything else is just simple primitive mappings.
public class Organization
{
public string dataType { get; set; }
public OrganizationData organizationData { get; set; }
}
public class OrganizationData
{
public int organizationNPI { get; set; }
public string organizationName { get; set; }
public string organizationTIN { get; set; }
public string website { get; set; }
public IEnumerable<Location> location { get; set; }
}
public class Location
{
public string addressLine1 { get; set; }
public string addressLine2 { get; set; }
public string city { get; set; }
public string state { get; set; }
public IEnumerable<Contact> contact { get; set; }
}
public class Contact
{
public string firstName { get; set; }
public string lastName { get; set; }
public string middleName { get; set; }
public string email { get; set; }
public string phone { get; set; }
}
Note that if this is a REST API then most likely they provide an Open API spec for it. In that case you don't need to generate this stuff by hand. Visual Studio can auto-generate the client and models given an Open API definition. You should go that route instead.
Also, the specialties and languages looks like an open-ended JSON object meaning the field names vary by the data being returned. If that is true then this cannot be directly done as properties on a class. However if literally the field names are language1
, language2
then you can follow the pattern I showed where specialty and language are classes with the given properties. Then add a property of each of these types to the Location
(??) type if that is what they relate to.