C# Hubspot Contacts class already built?


#1

Has anyone already built a C# Contacts class to deserialize the api returned json into?

Thanks!


#2

@cbarnes199 Hey there is a popular class built out that you can read up on and leverage to do this. It is called Json.NET. Here is a link to the documentation on it. Let me know if this helps or not.
http://www.newtonsoft.com/json


#3

@pmanca Yes Json.NET is a very good tool but are the .NET object classes for the HubSpot items (ie Contacts) already built somewhere so that we can use Json.NET to serialize/deserialize directly to strongly typed objects - without having to create the required object classes ourselves?
Thanks for your help!


#4

I found this pretty helpful. I could not use the results directly buy they saved a lot of typing.

http://json2csharp.com/

This will generate C# classes off the json and then you just have to do some tweaking out of the names with - in them that are not allowed.


#5

@cbarnes199 Thanks! That sounds good and will definitely check it out.


#6

Below is the hubspot api response in c# format obtained from json2csharp

public class HubSpotResponse
{
    public string status { get; set; }
    public string message { get; set; }
    public string correlationId { get; set; }
    public List<string> invalidEmails { get; set; }
    public List<FailureMessage> failureMessages { get; set; }
    public string requestId { get; set; }

    public class FailureMessage
    {
        public int index { get; set; }
        public Error error { get; set; }
    }
    public class Error
    {
        public string status { get; set; }
        public string message { get; set; }
    }

}