Below is my json string getting response from server. in this strig i want alternateLink String part which is "https://drive.google.com/file/d/2ferg6YSxertrewtaN_1iZc/view" how i can get this in another string variable

       "kind": "drive#file",

       "id": "2ferg6YSxertrewtaN_1G2re-5PDygeg",

       "alternateLink": "https://drive.google.com/file/d/2ferg6YSxertrewtaN_1iZc/view?usp=drivesdk",

       "embedLink": "https://drive.google.com/file/d/2fl6YSxfNweQwtaN_1G2IzuK-5PDyFwrc/preview?usp=drivesdk"
  • Deserialize the response into apex wrapper class and get the value from there.
    – RCS
    Commented May 11, 2018 at 6:17

1 Answer 1


You can create a wrapper class and use it further to get value of whatever field value required like follow:

public class sampleWrapperClass {

public String kind;
public String id;
public String alternateLink;
public String embedLink;

public static sampleWrapperClass  parse(String json) {
    return (sampleWrapperClass) System.JSON.deserialize(json, sampleWrapperClass.class);

Now that you have your wrapper structure ready, you can do following to get value of field alternatelink , execute following in execute anonymous window of developer console

sampleWrapperClass  objWrapper = sampleWrapperClass.parse(passYourJson);

This will give you,


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .