+ Start a Discussion
Craig PCraig P 

JSON.deserialize() not working

I am trying to use the JSON.deserialize() and it is not working. 

    public class MemberProfile {
        public Integer Id { get; set; }
        public String first_name { get; set; }
        public String last_name { get; set; }
        public String email { get; set; }



in my class....


MemberProfile memberProfile = (MemberProfile) JSON.deserialize(httpResponse.getBody(), MemberProfile.class);

 Error = Compile Error: Variable does not exist: MemberProfile.class






I am guessing that the version is less than v24:




The relevant part is here:


The apexType argument is the Apex type of the object that this method creates after deserializing the JSON content.
If the JSON content to parse contains attributes not present in the Apex type specified in the argument, such as a missing field or object, this method ignores these attributes and parses the rest of the JSON content. However, for Apex saved using Salesforce.com API version 24.0 or earlier, this method throws a run-time exception for missing attributes.

Hope this helps,