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
Ramakrishnan AyyanarRamakrishnan Ayyanar 

Json String deserialize help needed?

Thanks for Response.

I need one help.

i have json string value. i need to deserialize ths json string.

Json String Get Url:

http://api.crunchbase.com/v/2/organization/google?user_key=f781f4a0a7bedbad9861dd607069fd1b

Please use this url. need to deserialize ths mentioned url json string.

 
ShashankShashank (Salesforce Developers) 
You can use the JSON class's deserialize method for it: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_System_Json.htm#apex_System_Json_deserializeUntyped
https://developer.salesforce.com/page/Getting_Started_with_Apex_JSON
Naveen Rahul 3Naveen Rahul 3

Try the below codes.

public class HttpCalloutSample {

  // Pass in the endpoint to be used using the string url
  public String getCalloutResponseContents(String url) {

    // Instantiate a new http object
    Http h = new Http();

     // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
    HttpRequest req = new HttpRequest();
    req.setEndpoint(url);
    req.setMethod('GET');

    // Send the request, and return a response
    HttpResponse res = h.send(req);
    return res.getBody();
  }
}

String s = HttpCalloutSample.getCalloutResponseContents('http://api.crunchbase.com/v/2/organization/google?user_key=f781f4a0a7bedbad9861dd607069fd1b');
Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(s);
List<Object> pricing = (List<Object>) m.get('pricing');
for (Object o : pricing) {
    Map<String, Object> p = (Map<String, Object>) o;
    System.debug('>>> ' + p);
}

 

Thanks
D Naveen Rahul.