I have JSON file which contains multiple arrays of objects:
{
"projects":[{
"issuetypes":[{
"fields":{
"priority":{
"allowedValues":[{
"self":"",
"iconUrl":"",
"name":"",
"id":"1"
}]
},
"components":{
"allowedValues":[{
"self":"",
"id":"",
"name":""
}
And I tried to parse it to C# class.
Google have examples only with simplified version of deserializing JSON do C# Object.
What I created now ?
public class RootObject
{
[JsonProperty(PropertyName = "projects")]
public List<ProjectObject> Projects { get; set; }
}
public class ProjectObject
{
[JsonProperty(PropertyName = "issueTypes")]
public List<IssueObject> Issues { get; set; }
}
public class IssueObject
{
[JsonProperty(PropertyName = "fields")]
public FieldObject Field { get; set; }
}
public class FieldObject
{
[JsonProperty(PropertyName = "components")]
public ComponentObject Component { get; set; }
[JsonProperty(PropertyName = "priority")]
public PriorityObject Priority { get; set; }
}
public class PriorityObject
{
[JsonProperty(PropertyName = "value")]
public PriorityAllowedValues PriorityValues { get; set; }
}
public class PriorityAllowedValues
{
public List<PriorityValues> AllowedValues { get; set; }
}
public class PriorityValues
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "self")]
public string Self { get; set; }
[JsonProperty(PropertyName = "iconUrl")]
public string IconUrl { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
}
public class ComponentObject
{
[JsonProperty(PropertyName = "value")]
public ComponentAllowedValues ComponentAllowedValues { get; set; }
}
public class ComponentAllowedValues
{
public List<SelectObject> AllowedValues { get; set; }
}
public class SelectObject
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "self")]
public string Self { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
}
And when I am trying to execute this line:
RootObject root = JsonConvert.DeserializeObject<RootObject>(data);
Data from JSON file should go properly to RootObject...
There are some tools which can help you generate classes from JSON, e.g. https://jsonutils.com/
This structure should work for provided json:
public class AllowedValue
{
[JsonProperty("self")]
public string Self { get; set; }
[JsonProperty("iconUrl")]
public string IconUrl { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
}
public class Priority
{
[JsonProperty("allowedValues")]
public IList<AllowedValue> AllowedValues { get; set; }
}
public class AllowedValue
{
[JsonProperty("self")]
public string Self { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class Components
{
[JsonProperty("allowedValues")]
public IList<AllowedValue> AllowedValues { get; set; }
}
public class Fields
{
[JsonProperty("priority")]
public Priority Priority { get; set; }
[JsonProperty("components")]
public Components Components { get; set; }
}
public class Issuetype
{
[JsonProperty("fields")]
public Fields Fields { get; set; }
}
public class Project
{
[JsonProperty("issuetypes")]
public IList<Issuetype> Issuetypes { get; set; }
}
public class RootObject
{
[JsonProperty("projects")]
public IList<Project> Projects { get; set; }
}
Related
My JSON file
[
{
"amount":"1000000.0",
"check_number":1,
"payment_number":5,
"attachments":[
{
"id":5324,
"url":"http://www.example.com/",
"filename":"january_receipt_copy.jpg"
}
]
}
]
My Class File
public class Attachment
{
public int id { get; set; }
public string url { get; set; }
public string filename { get; set; }
}
public class AccountDetail
{
public string amount { get; set; }
public int check_number { get; set; }
public int payment_number { get; set; }
}
public class RootObject
{
public AccountDetail accountdetail{ get; set; }
public List<Attachment> attachments { get; set; }
}
Now I want to map JSON file's properties 'check_number','amount' etc
to accountdetail by using newtonsoft JSON deserialization.
You need the following two classes:
public class Attachment
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("filename")]
public string Filename { get; set; }
}
public class AccountDetails
{
[JsonProperty("amount")]
public string Amount { get; set; }
[JsonProperty("check_number")]
public int CheckNumber { get; set; }
[JsonProperty("payment_number")]
public int PaymentNumber { get; set; }
[JsonProperty("attachments")]
public IList<Attachment> Attachments { get; set; }
}
By defining the above classes you can deserialize your json as below:
var accountsDetails = JsonConvert.DeserializeObject<IEnumerable<AccountDetails>>(json);
This question already has answers here:
What is a NullReferenceException, and how do I fix it?
(27 answers)
Closed 6 years ago.
I have created class of below json using json2csharp.
{
"saveExistingRetailCustomerReq":{
"reqHdr":{
"consumerContext":{
"applicationId":"CRM",
"terminalId":"12345"
},
"serviceContext":{
"uniqueMsgId":"111121362162",
"reqMsgDateTime":"2016-09-02T11:19:15.754",
"timeZone":"2016-09-02T11:19:15.754",
"serviceName":"saveExistingRetailCustomer",
"serviceVersion":"1",
"conversationId":"2121211",
"parentMsgId":" 3132121"
},
"providerContext":{
"providerId":"CBS"
},
"userContext":{
"userId":" 132123"
},
"additionalDetails":{
"details":"1"
}
},
"body":{
"customerDtls":{
"custId":"22551",
"firstName":"First",
"lastName":"Last",
"middleName":"Middle",
"customerStatus":"DCSED",
"dateOfNotification":"2016-10-01T00:00:00.000",
"dateOfDeath":"2016-10-01T00:00:00.000",
"isSuspended":"Y",
"isNegated":"N",
"isBlacklisted":"N",
"gender":"",
"dateOfBirth":"1991-08-12T00:00:00.000",
"nativeLanguage":"Language",
"occupation":"",
"preferredName":"preferred",
"shortName":"short",
"primarySolId":"1100",
"title":"",
"SMSBankingMobNum":"9092480244",
"IsSMSBankingEnabled":"N",
"IsEBankingEnabled":"N",
"staffEmployeeID":"",
"staffFlag":"N",
"relatedDtls":{
"employmentStatus":"Salaried",
"maritalStatus":"002",
"nationality":"F"
},
"communicationDtls":{
"phoneDtls":{
"cityCode":"91",
"countryCode":"91",
"mobileNumber":"9092480244",
"phoneOrEmail":"PHONE",
"prefFlag":"Y",
"type":"HOMEPH1"
},
"emailDtls":{
"email":"test#email.com",
"type":"HOMEEML",
"phoneOrEmail":"EMAIL",
"prefFlag":"Y"
}
},
"addressDtls":[
{
"addressLine1":"AddressLine1",
"addressLine2":"AddressLine2",
"addressLine3":"AddressLine3",
"addressCategory":"Mailing",
"city":"C001",
"country":"IN",
"freeTextLabel":"RETAL",
"preferredAddress":"N",
"preferredFormat":"FREE_TEXT_FORMAT",
"startDt":"2005-07-02T00:00:00.000",
"state":"S001",
"postalCode":"507001"
},
{
"addressLine1":"Line1Address",
"addressLine2":"Line2Address",
"addressLine3":"Line3Address",
"addressCategory":"Swift",
"city":"C001",
"country":"IN",
"freeTextLabel":"RETAL",
"preferredAddress":"Y",
"preferredFormat":"FREE_TEXT_FORMAT",
"startDt":"2005-07-02T00:00:00.000",
"state":"S001",
"postalCode":"507001"
}
],
"documentDtls":[
{
"countryOfIssue":"IN",
"docCode":"IDPC",
"issueDt":"2015-09-12T00:00:00.000",
"type":"ID",
"placeOfIssue":"C001",
"referenceNum":"XYZ123VW45",
"preferredUniqueId":"Y",
"idIssuedOrganisation":"GOI"
},
{
"countryOfIssue":"IN",
"docCode":"IDVC",
"issueDt":"2015-08-12T00:00:00.000",
"type":"ID",
"placeOfIssue":"C001",
"referenceNum":"DEF123VW45",
"preferredUniqueId":"N",
"idIssuedOrganisation":"GOI"
}
]
}
}
}
}
Below is the Class created by json2Csharp.
using System.Collections.Generic;
namespace CRMnext.Ujjivan.DLL
{
public class ConsumerContext
{
public string applicationId { get; set; }
public string terminalId { get; set; }
}
public class ServiceContext
{
public string uniqueMsgId { get; set; }
public string reqMsgDateTime { get; set; }
public string timeZone { get; set; }
public string serviceName { get; set; }
public string serviceVersion { get; set; }
public string conversationId { get; set; }
public string parentMsgId { get; set; }
}
public class ProviderContext
{
public string providerId { get; set; }
}
public class UserContext
{
public string userId { get; set; }
}
public class AdditionalDetails
{
public string details { get; set; }
}
public class ReqHdr
{
public ConsumerContext consumerContext { get; set; }
public ServiceContext serviceContext { get; set; }
public ProviderContext providerContext { get; set; }
public UserContext userContext { get; set; }
public AdditionalDetails additionalDetails { get; set; }
}
public class RelatedDtls
{
public string employmentStatus { get; set; }
public string maritalStatus { get; set; }
public string nationality { get; set; }
}
public class PhoneDtls
{
public string cityCode { get; set; }
public string countryCode { get; set; }
public string mobileNumber { get; set; }
public string phoneOrEmail { get; set; }
public string prefFlag { get; set; }
public string type { get; set; }
}
public class EmailDtls
{
public string email { get; set; }
public string type { get; set; }
public string phoneOrEmail { get; set; }
public string prefFlag { get; set; }
}
public class CommunicationDtls
{
public PhoneDtls phoneDtls { get; set; }
public EmailDtls emailDtls { get; set; }
}
public class AddressDtl
{
public string addressLine1 { get; set; }
public string addressLine2 { get; set; }
public string addressLine3 { get; set; }
public string addressCategory { get; set; }
public string city { get; set; }
public string country { get; set; }
public string freeTextLabel { get; set; }
public string preferredAddress { get; set; }
public string preferredFormat { get; set; }
public string startDt { get; set; }
public string state { get; set; }
public string postalCode { get; set; }
}
public class DocumentDtl
{
public string countryOfIssue { get; set; }
public string docCode { get; set; }
public string issueDt { get; set; }
public string type { get; set; }
public string placeOfIssue { get; set; }
public string referenceNum { get; set; }
public string preferredUniqueId { get; set; }
public string idIssuedOrganisation { get; set; }
}
public class CustomerDtls
{
public string custId { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string middleName { get; set; }
public string customerStatus { get; set; }
public string dateOfNotification { get; set; }
public string dateOfDeath { get; set; }
public string isSuspended { get; set; }
public string isNegated { get; set; }
public string isBlacklisted { get; set; }
public string gender { get; set; }
public string dateOfBirth { get; set; }
public string nativeLanguage { get; set; }
public string occupation { get; set; }
public string preferredName { get; set; }
public string shortName { get; set; }
public string primarySolId { get; set; }
public string title { get; set; }
public string SMSBankingMobNum { get; set; }
public string IsSMSBankingEnabled { get; set; }
public string IsEBankingEnabled { get; set; }
public string staffEmployeeID { get; set; }
public string staffFlag { get; set; }
public RelatedDtls relatedDtls { get; set; }
public CommunicationDtls communicationDtls { get; set; }
public List<AddressDtl> addressDtls { get; set; }
public List<DocumentDtl> documentDtls { get; set; }
}
public class Body
{
public CustomerDtls customerDtls { get; set; }
}
public class SaveExistingRetailCustomerReq
{
public ReqHdr reqHdr { get; set; }
public Body body { get; set; }
}
public class RootObject
{
public SaveExistingRetailCustomerReq saveExistingRetailCustomerReq { get; set; }
}
}
In the next step I want to pass values in this created class. After that by serializing object of this class I want to pass that serialized Json to one service I am consuming. I have tried below by referring Turn C# object into a JSON string in .NET 4. But getting error Object reference not set to an instance of an object.
RootObject rootObject = new RootObject();
rootObject.saveExistingRetailCustomerReq.reqHdr.consumerContext.applicationId = "CRM";
var jsonData = JsonConvert.SerializeObject(rootObject);
If I am doing anything wrong then I would appreciate if anyone could guide me in this process.
You need create all objects not only RootObject.
RootObject rootObject = new RootObject();
rootObject.saveExistingRetailCustomerReq = new SaveExistingRetailCustomerReq();
rootObject.saveExistingRetailCustomerReq.reqHdr = new ReqHdr();
rootObject.saveExistingRetailCustomerReq.reqHdr.consumerContext = new ConsumerContext();
rootObject.saveExistingRetailCustomerReq.reqHdr.consumerContext.applicationId = "CRM";
var jsonData = JsonConvert.SerializeObject(rootObject);
I have this json
and i want to deserialize it so I can get each object's value for example:
"icon_url": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpouLWzKjhzw8zFdC5K092kl5SClMj3PLXFhGpC_Pp8j-3I4IG7i1Hn_UI-Nmj3ItDGe1BoN1mCr1G4xL_vhMS8tcmcn3JhuihwsHvbzQv3309k3tBw8A",
The problem is I can make the class(es) that I need so I can deserialize the json because the json string has nested objects.
I used json2csharp to help me generate classes. After some merging and cleaning up, this is what I got:
public class InventoryItem
{
public string id { get; set; }
public string classid { get; set; }
public string instanceid { get; set; }
public string amount { get; set; }
public int pos { get; set; }
}
public class AppData
{
public string def_index { get; set; }
public int? is_itemset_name { get; set; }
public int? limited { get; set; }
}
public class Description
{
public string type { get; set; }
public string value { get; set; }
public string color { get; set; }
public AppData app_data { get; set; }
}
public class Action
{
public string name { get; set; }
public string link { get; set; }
}
public class Tag
{
public string internal_name { get; set; }
public string name { get; set; }
public string category { get; set; }
public string category_name { get; set; }
public string color { get; set; }
}
public class RgDescription
{
public string appid { get; set; }
public string classid { get; set; }
public string instanceid { get; set; }
public string icon_url { get; set; }
public string icon_url_large { get; set; }
public string icon_drag_url { get; set; }
public string name { get; set; }
public string market_hash_name { get; set; }
public string market_name { get; set; }
public string name_color { get; set; }
public string background_color { get; set; }
public string type { get; set; }
public int tradable { get; set; }
public int marketable { get; set; }
public int commodity { get; set; }
public string market_tradable_restriction { get; set; }
public List<Description> descriptions { get; set; }
public List<Action> actions { get; set; }
public List<Action> market_actions { get; set; }
public List<Tag> tags { get; set; }
}
public class RootObject
{
public bool success { get; set; }
public IDictionary<string, InventoryItem> rgInventory { get; set; }
public List<object> rgCurrency { get; set; }
public IDictionary<string, RgDescription> rgDescriptions { get; set; }
public bool more { get; set; }
public bool more_start { get; set; }
}
These appear to work correctly, you can deserialize and serialize with code like this:
var obj = JsonConvert.DeserializeObject<RootObject>(oldString);
Console.WriteLine(obj.rgDescriptions["310776560_302028390"].icon_url); // e.g.
var newString = JsonConvert.SerializeObject(obj,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
// null value handling is optional, the above makes it a little more like the source string
I'm using the Petfinder API and trying to return a root object in my C# code. I used the Json class generator to generate the classes, but the Deserialize function is returning nulls.
This is my C# code:
using (var client = new WebClient())
{
var json = new WebClient().DownloadString("http://api.petfinder.com/shelter.getPets?format=json&key=<key>&id=<id>");
Petfinder deserializedPet = JsonConvert.DeserializeObject<Petfinder>(json);
}
The Petfinder object is defined as:
internal class Petfinder
{
[JsonProperty("#xmlns:xsi")]
public string XmlnsXsi { get; set; }
[JsonProperty("lastOffset")]
public LastOffset LastOffset { get; set; }
[JsonProperty("pets")]
public Pets Pets { get; set; }
[JsonProperty("header")]
public Header Header { get; set; }
[JsonProperty("#xsi:noNamespaceSchemaLocation")]
public string XsiNoNamespaceSchemaLocation { get; set; }
}
The first few lines of the json string is as follows:
{"#encoding":"iso-8859-1","#version":"1.0","petfinder":{"#xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","lastOffset":{"$t":"25"},"pets":{"pet":[{"options":{"option":[{"$t":"hasShots"},{"$t":"altered"},{"$t":"housetrained"}]},"breeds":{"breed":{"$t":"Domestic Medium Hair"}},"shelterPetId":{},"status":{"$t":"A"},"name":{"$t":"Jasmine"},...
If that helps at all.
I'm a newbie to json.net. What am I doing wrong?
Your class is wrong, take a look at the output from json2csharp.com for the example json you provided. Obviously the __invalid_name_$t needs to be manually fixed and the mapped using [JsonProperty].
public class LastOffset
{
public string __invalid_name__$t { get; set; }
}
public class Option
{
public string __invalid_name__$t { get; set; }
}
public class Options
{
public List<Option> option { get; set; }
}
public class Breed
{
public string __invalid_name__$t { get; set; }
}
public class Breeds
{
public Breed breed { get; set; }
}
public class ShelterPetId
{
}
public class Status
{
public string __invalid_name__$t { get; set; }
}
public class Name
{
public string __invalid_name__$t { get; set; }
}
public class Pet
{
public Options options { get; set; }
public Breeds breeds { get; set; }
public ShelterPetId shelterPetId { get; set; }
public Status status { get; set; }
public Name name { get; set; }
}
public class Pets
{
public List<Pet> pet { get; set; }
}
public class Petfinder
{
public string __invalid_name__#xmlns:xsi { get; set; }
public LastOffset lastOffset { get; set; }
public Pets pets { get; set; }
}
public class RootObject
{
public string __invalid_name__#encoding { get; set; }
public string __invalid_name__#version { get; set; }
public Petfinder petfinder { get; set; }
}
I am trying to generate C# class using the JSON string from here http://json2csharp.com/ this works fine. But I can't parse the JSON to the object generated by the website.
Here is the JSON string
{
"searchParameters":{
"key":"**********",
"system":"urn:oid:.8"
},
"message":" found one Person matching your search criteria.",
"_links":{
"self":{
"href":"https://integration.rest.api.test.com/v1/person?key=123456&system=12.4.34.."
}
},
"_embedded":{
"person":[
{
"details":{
"address":[
{
"line":["5554519 testdr"],
"city":"testland",
"state":"TT",
"zip":"12345",
"period":{
"start":"2003-10-22T00:00:00Z",
"end":"9999-12-31T23:59:59Z"
}
}
],
"name":[
{
"use":"usual",
"family":["BC"],
"given":["TWO"],
"period":{
"start":"9999-10-22T00:00:00Z",
"end":"9999-12-31T23:59:59Z"
}
}
],
"gender":{
"code":"M",
"display":"Male"
},
"birthDate":"9999-02-03T00:00:00Z",
"identifier":[
{
"use":"unspecified",
"system":"urn:oid:2.19.8",
"key":"",
"period":{
"start":"9999-10-22T00:00:00Z",
"end":"9999-12-31T23:59:59Z"
}
}
],
"telecom":[
{
"system":"email",
"value":"test#test.com",
"use":"unspecified",
"period":{
"start":"9999-10-22T00:00:00Z",
"end":"9999-12-31T23:59:59Z"
}
}
],
"photo":[
{
"content":{
"contentType":"image/jpeg",
"language":"",
"data":"",
"size":0,
"hash":"",
"title":"My Picture"
}
}
]
},
"enrolled":true,
"enrollmentSummary":{
"dateEnrolled":"9999-02-07T21:39:11.174Z",
"enroller":"test Support"
},
"_links":{
"self":{
"href":"https://integration.rest.api.test.com/v1/person/-182d-4296-90cc"
},
"unenroll":{
"href":"https://integration.rest.api.test.com/v1/person/1b018dc4-182d-4296-90cc-/unenroll"
},
"personLink":{
"href":"https://integration.rest.api.test.com/v1/person/-182d-4296-90cc-953c/personLink"
},
"personMatch":{
"href":"https://integration.rest.api.commonwellalliance.org/v1/person/-182d-4296-90cc-/personMatch?orgId="
}
}
}
]
}
}
Here is the code I use to convert to the object.
JavaScriptSerializer js = new JavaScriptSerializer();
var xx = (PersonsearchVM)js.Deserialize(jsonstr, typeof(PersonsearchVM));
Is there any other wat to generate the object and parse?
I think you have some invalid characters in your JSON string. Run it through a validator and add the necessary escape characters.
http://jsonlint.com/
You aren't casting it to the right object. Cast it to the type RootObject.
Eg
JavaScriptSerializer js = new JavaScriptSerializer();
var xx = (RootObject)js.Deserialize(jsonstr, typeof(RootObject));
The code that json 2 csharp creates is this:
public class SearchParameters
{
public string key { get; set; }
public string system { get; set; }
}
public class Self
{
public string href { get; set; }
}
public class LinKs
{
public Self self { get; set; }
}
public class Period
{
public string start { get; set; }
public string end { get; set; }
}
public class Address
{
public List<string> line { get; set; }
public string city { get; set; }
public string __invalid_name__state { get; set; }
public string zip { get; set; }
public Period period { get; set; }
}
public class PerioD2
{
public string start { get; set; }
public string end { get; set; }
}
public class Name
{
public string use { get; set; }
public List<string> family { get; set; }
public List<string> given { get; set; }
public PerioD2 __invalid_name__perio
d { get; set; }
}
public class Gender
{
public string __invalid_name__co
de { get; set; }
public string display { get; set; }
}
public class Period3
{
public string start { get; set; }
public string __invalid_name__end { get; set; }
}
public class Identifier
{
public string use
{ get; set; }
public string system { get; set; }
public string key { get; set; }
public Period3 period { get; set; }
}
public class Period4
{
public string start { get; set; }
public string end { get; set; }
}
public class Telecom
{
public string system { get; set; }
public string value { get; set; }
public string use { get; set; }
public Period4 period { get; set; }
}
public class Content
{
public string contentType { get; set; }
public string language { get; set; }
public string __invalid_name__dat
a { get; set; }
public int size { get; set; }
public string hash { get; set; }
public string title { get; set; }
}
public class Photo
{
public Content content { get; set; }
}
public class Details
{
public List<Address> address { get; set; }
public List<Name> name { get; set; }
public Gender gender { get; set; }
public string birthDate { get; set; }
public List<Identifier> identifier { get; set; }
public List<Telecom> telecom { get; set; }
public List<Photo> photo { get; set; }
}
public class EnrollmentSummary
{
public string dateEnrolled { get; set; }
public string __invalid_name__en
roller { get; set; }
}
public class Self2
{
public string href { get; set; }
}
public class UnEnroll
{
public string href { get; set; }
}
public class PersonLink
{
public string href { get; set; }
}
public class PersonMatch
{
public string href { get; set; }
}
public class Links2
{
public Self2 self { get; set; }
public UnEnroll __invalid_name__un
enroll { get; set; }
public PersonLink personLink { get; set; }
public PersonMatch personMatch { get; set; }
}
public class Person
{
public Details details { get; set; }
public bool __invalid_name__e
nrolled { get; set; }
public EnrollmentSummary enrollmentSummary { get; set; }
public Links2 _links { get; set; }
}
public class Embedded
{
public List<Person> person { get; set; }
}
public class RootObject
{
public SearchParameters searchParameters { get; set; }
public string message { get; set; }
public LinKs __invalid_name___lin
ks { get; set; }
public Embedded _embedded { get; set; }
}
The following function will convert JSON into a C# class where T is the class type.
public static T Deserialise<T>(string json)
{
T obj = Activator.CreateInstance<T>();
using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
obj = (T)serializer.ReadObject(ms); //
return obj;
}
}
You need a reference to the System.Runtime.Serialization.json namespace.
The function is called in the following manner;
calendarList = Deserialise<GoogleCalendarList>(calendarListString);
calendarlist being the C# class and calendarListString the string containing the JSON.