function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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

 

 

 

 

SFFSFF

I am guessing that the version is less than v24:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_json.htm

 

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,