Help with error in deserialization?????

Jan 6, 2009 at 12:06 AM
This is my responce from Myspace
{

    "totalResults":1,
    "startIndex":1,
    "itemsPerPage":1,
    "sorted":false,
    "filtered":false
    "entry":[
    {
        "id":"myspace.com:26000010",
        "nickname":"shaka",
        "profileUrl":"http:\/\/www.myspace.com\/shakasarah",
        "thumbnailUrl":"http:\/\/a229.ac-
        images.myspacecdn.com\/images01\/118\/s_3dcfafe8145a40fc46edacfebe7eaa94.jpg"

    }
    ]
}
This is my Class

 public class Person
    {
        public string fname { get; set; }
        public string mname { get; set; }
        public string lname { get; set; }

        #region MySpace Properties
        public string name { get; set; }
        public string displayName { get; set; }
        public string familyName { get; set; }
        public string givenName { get; set; }
        public string nickName { get; set; }
        public string id { get; set; }
        public string hasApp { get; set; }
        public string[] emails { get; set; }
        public DateTime dateOfBirth { get; set; }
        public int age { get; set; }
        #endregion

        public static Person getjson(OAuth.Net.Consumer.OAuthResponse response)
        {
            StreamReader irr = new StreamReader(response.ProtectedResource.GetResponseStream());
            string body = irr.ReadToEnd();
            irr.Close();

            Person deserializedPerson = (Person)JavaScriptConvert.DeserializeObject(body, typeof(Person));
            return deserializedPerson;


        }

    }
This is my error..

Could not find member 'entry' on object of type 'RuntimeType'

Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details: Newtonsoft.Json.JsonSerializationException: Could not find member 'entry' on object of type 'RuntimeType'

Source Error:

Line 518:      {Line 519:        if (_missingMemberHandling == MissingMemberHandling.Error)Line 520:          throw new JsonSerializationException("Could not find member '{0}' on object of type '{1}'".FormatWith(CultureInfo.InvariantCulture, memberName, targetType.GetType().Name));Line 521:      }Line 522:    }

Source File: J:\SocialCelebrityNet\Json\Src\Newtonsoft.Json\JsonSerializer.cs    Line: 520

Help please i would like to deserialize only the entry section into the person object.


Coordinator
Jan 6, 2009 at 8:08 AM
Load the JSON into a JObject, get the piece of JSON you want, create a reader from it and pass it to the serializer.