Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:24:50+00:00 2026-06-05T16:24:50+00:00

I am deserializing yahoo contacts api’s json response everything is going good but I

  • 0

I am deserializing yahoo contacts api’s json response everything is going good but I am getting issue in one field fields, its a array but in all elements value is different different, how can handle it. In two fields this is string and in other element object. here is my sample json

"fields": [
      {
       "created": "2008-12-29T13:47:21Z",
       "updated": "2008-12-29T13:47:21Z",
       "uri": "http://social.yahooapis.com/v1/user/ASASASASASASA/contact/8/email/18",
       "id": "18",
       "type": "email",
       "value": "papi@ymail.com",
       "editedBy": "OWNER"
      },
      {
       "created": "2010-03-30T07:02:04Z",
       "updated": "2011-06-25T05:01:51Z",
       "uri": "http://social.yahooapis.com/v1/user/ASASASASASASA/contact/8/guid/42",
       "id": "42",
       "type": "guid",
       "value": "BMM5JTQVDB7G4EBPO2D5ESE3TI",
       "editedBy": "OWNER",
       "isConnection": "false"
      },
      {
       "created": "2008-12-29T13:47:21Z",
       "updated": "2008-12-29T13:47:21Z",
       "uri": "http://social.yahooapis.com/v1/user/ASASASASASASA/contact/8/name/17",
       "id": "17",
       "type": "name",
       "value": {
        "givenName": "Hitesh",
        "middleName": null,
        "familyName": "Lohar",
        "prefix": null,
        "suffix": null,
        "givenNameSound": null,
        "familyNameSound": null
       },
       "editedBy": "OWNER"
      }
     ]

I created following class for Field

public class YahooField
    {
        [JsonProperty("created")]
        public string Created { get; set; }

        [JsonProperty("updated")]
        public string Updated { get; set; }

        [JsonProperty("uri")]
        public string Uri { get; set; }

        [JsonProperty("id")]
        public string Id { get; set; }

        [JsonProperty("type")]
        public string Type { get; set; }

        //here confusion
        //[JsonProperty("value")]
        //public (String or class) Value { get; set; }

        [JsonProperty("editedBy")]
        public string EditedBy { get; set; }

        [JsonProperty("isConnection")]
        public string IsConnection { get; set; }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:24:51+00:00Added an answer on June 5, 2026 at 4:24 pm

    The value property is just another object.
    Create a new class called ValueField and add some properties:

    1. GivenName
    2. MiddleName
    3. FamilyName
    4. Prefix
    5. Suffix
    6. GivenNameSound
    7. FamilyNameSound

    And add this class as a property to your YahooField class

    public class YahooField
        {
            [JsonProperty("created")]
            public string Created { get; set; }
    
            [JsonProperty("updated")]
            public string Updated { get; set; }
    
            [JsonProperty("uri")]
            public string Uri { get; set; }
    
            [JsonProperty("id")]
            public string Id { get; set; }
    
            [JsonProperty("type")]
            public string Type { get; set; }
    
            [JsonProperty("value")]
            public ValueField Value { get; set; }
    
            [JsonProperty("editedBy")]
            public string EditedBy { get; set; }
    
            [JsonProperty("isConnection")]
            public string IsConnection { get; set; }
        }
    

    You should write your own contract resolver to detect if the property Value is of type String or not. This way you can interrupt the default behaviour and implement your own logic.

    Just derive your CustomContractResolver from DefaultContractResolver and override the virtual methods you need for your implementation.

    public class CustomContractResolver: DefaultContractResolver
    {
    //override the methods you need.
    }
    

    You can set your custom contract resolver by doing the following:

      JsonConvert.SerializeObject(
        product,
        Formatting.Indented,
        new JsonSerializerSettings { ContractResolver = new CustomContractResolver() }
      );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For deserializing json with unknown field into an object there's @JsonAnySetter. But what if
Another question, but it relates to this one: Deserializing JSON with Jackson - Why
I'm having problems deserializing some json data, getting InvalidCastExceptions and the like. Can anyone
I have a problem deserializing a JSON string using Jackson (but I have no
The question is similar to Deserializing JSON with unknown fields but I would like
I have found lots of online tutorials but all of them are deserializing JSON
I have a problem with deserializing JSON data from an external REST service. Depending
I have a Java class MyPojo that I am interested in deserializing from JSON.
I am having the same issues as per this question: WCF not deserializing JSON
Should one create unit tests involving IO? Ie, testing a class method for serializing/deserializing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.