<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calling a REST Web Service (JSON) with Apex</title>
	<atom:link href="http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=calling-a-json-rest-web-service-with-apex</link>
	<description>Get your head out of your #@! and into the clouds!</description>
	<lastBuildDate>Fri, 10 Sep 2010 10:10:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: James Wikkerink</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-366</link>
		<dc:creator>James Wikkerink</dc:creator>
		<pubDate>Tue, 20 Apr 2010 22:56:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-366</guid>
		<description>Well it turns out there was nothing wrong with the JSON parser. I needed to remove all the carriage returns before passing it to the parser (\r\n).</description>
		<content:encoded><![CDATA[<p>Well it turns out there was nothing wrong with the JSON parser. I needed to remove all the carriage returns before passing it to the parser (\r\n).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Wikkerink</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-365</link>
		<dc:creator>James Wikkerink</dc:creator>
		<pubDate>Tue, 20 Apr 2010 00:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-365</guid>
		<description>I downloaded the most recent verson of the JSON google code project for Salesforce and it has problems parsing my geocode response. Here is a sample (is it really that crazy?). It definitely did not like the attributes key without a value which I fixed, but it gets lost elsewhere (trying to figure where) also:

{
  &quot;candidates&quot; : [
    {
      &quot;address&quot; : &quot;380 NEW YORK ST, REDLANDS, CA, 92373&quot;,
      &quot;location&quot; :
      {
        &quot;x&quot; : -117.195681386,
        &quot;y&quot; : 34.0575170970001
      },
      &quot;score&quot; : 81,
      &quot;attributes&quot; :
      {
      }
    },
    {
      &quot;address&quot; : &quot;458 NEW YORK ST, REDLANDS, CA, 92373&quot;,
      &quot;location&quot; :
      {
        &quot;x&quot; : -117.19569688,
        &quot;y&quot; : 34.0585149200002
      },
      &quot;score&quot; : 41,
      &quot;attributes&quot; :
      {
      }
    }, ...
  ]
}</description>
		<content:encoded><![CDATA[<p>I downloaded the most recent verson of the JSON google code project for Salesforce and it has problems parsing my geocode response. Here is a sample (is it really that crazy?). It definitely did not like the attributes key without a value which I fixed, but it gets lost elsewhere (trying to figure where) also:</p>
<p>{<br />
  &#8220;candidates&#8221; : [<br />
    {<br />
      "address" : "380 NEW YORK ST, REDLANDS, CA, 92373",<br />
      "location" :<br />
      {<br />
        "x" : -117.195681386,<br />
        "y" : 34.0575170970001<br />
      },<br />
      "score" : 81,<br />
      "attributes" :<br />
      {<br />
      }<br />
    },<br />
    {<br />
      "address" : "458 NEW YORK ST, REDLANDS, CA, 92373",<br />
      "location" :<br />
      {<br />
        "x" : -117.19569688,<br />
        "y" : 34.0585149200002<br />
      },<br />
      "score" : 41,<br />
      "attributes" :<br />
      {<br />
      }<br />
    }, ...<br />
  ]<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose Ibarra</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-364</link>
		<dc:creator>Jose Ibarra</dc:creator>
		<pubDate>Tue, 13 Apr 2010 16:33:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-364</guid>
		<description>Thanks for your support, If I copy and save the same code it work, but I am calling a future process and I can not have any method different to void.</description>
		<content:encoded><![CDATA[<p>Thanks for your support, If I copy and save the same code it work, but I am calling a future process and I can not have any method different to void.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Douglas</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-363</link>
		<dc:creator>Jeff Douglas</dc:creator>
		<pubDate>Thu, 08 Apr 2010 19:56:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-363</guid>
		<description>You might want to check out this new project on code share, &lt;a href=&quot;http://developer.force.com/codeshare/apex/ProjectPage?id=a06300000062Z2kAAE&quot; rel=&quot;nofollow&quot;&gt;Fast Xml DOM&lt;/a&gt;. Not sure if it will help.</description>
		<content:encoded><![CDATA[<p>You might want to check out this new project on code share, <a href="http://developer.force.com/codeshare/apex/ProjectPage?id=a06300000062Z2kAAE" rel="nofollow">Fast Xml DOM</a>. Not sure if it will help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose Ibarra</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-362</link>
		<dc:creator>Jose Ibarra</dc:creator>
		<pubDate>Thu, 08 Apr 2010 13:16:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-362</guid>
		<description>I am very happy to find this class, but I have an error in some section of this code,  I hope you can help me to find this error, I already copy the class JSONObject in setup-&gt;develop-&gt;apex class.

Do you have any manuals or another way to parse it with json?

below code

 GetLatLon_json{
  //Future annotation to mark the method as async.
  @Future(callout=true)

//  String id, String name
public static void GetLatLon_json_Request () {

    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint(&#039;http://maps.google.com/maps/api/geocode/xml?address=torre+parquecristal+caracas+venezuela&amp;sensor=true&#039;);
    req.setMethod(&#039;GET&#039;);

     HTTPResponse resp = http.send(req);

    String json;

    json = resp.getBody().replace(&#039;\n&#039;, &#039;&#039;);
/*****

//***** XML received****


 OK

  street_address
  1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA

   1600
   1600
   street_number


   Amphitheatre Pkwy
   Amphitheatre Pkwy
   route


   Mountain View
   Mountain View
   locality
   political


   San Jose
   San Jose
   administrative_area_level_3
   political


   Santa Clara
   Santa Clara
   administrative_area_level_2
   political


   California
   CA
   administrative_area_level_1
   political


   United States
   US
   country
   political


   94043
   94043
   postal_code



    37.4217550
    -122.0846330

   ROOFTOP


     37.4188514
     -122.0874526


     37.4251466
     -122.0811574






         */

    JSONObject j = new JSONObject( json );

    JSONObject resp2;
    /*
    //*****First option *****
    // I will change this section witht he correct data and fields after solve the error of semi colon.

    public String toDisplayString() {  /**  error message &quot;Error de compilación: expecting a semi-colon, found &#039;(&#039; &quot; after &quot;toDisplayString&quot;
            return address + &#039; [&#039;
            + coordinate1 + &#039;, &#039;
            + coordinate2 + &#039;, &#039;
            + coordinate3 + &#039;] - Status: &#039;
            + statusCode;
        }

      resp2 = (j).toDisplayString();

*/

/*
//*****second option *****

    resp2 = j.getValues(&#039;GeocodeResponse&#039;); //**** Method does not exist or incorrect signature: [JSONObject].getValues(String

  */


      //check the response
    if (resp.getStatusCode() == 200) {
      System.debug(&#039;Exitoso &#039;+ resp);
      Event acc = new Event(Id=&#039;00U3000000AGFnJEAX&#039;);
      acc.Description = &#039; Created &#039;+datetime.now() ;
      Update acc;

    } else {
      System.debug(&#039;Callout failed: &#039; + resp);
      Event acc = new Event(Id=&#039;00U3000000AGFnJEAX&#039;);
      acc.Description = &#039;Malo  fecha&#039;+datetime.now() ;
      update acc;

    } //else

    }//method


}//class

Best Regards</description>
		<content:encoded><![CDATA[<p>I am very happy to find this class, but I have an error in some section of this code,  I hope you can help me to find this error, I already copy the class JSONObject in setup-&gt;develop-&gt;apex class.</p>
<p>Do you have any manuals or another way to parse it with json?</p>
<p>below code</p>
<p> GetLatLon_json{<br />
  //Future annotation to mark the method as async.<br />
  @Future(callout=true)</p>
<p>//  String id, String name<br />
public static void GetLatLon_json_Request () {</p>
<p>    Http http = new Http();<br />
    HttpRequest req = new HttpRequest();<br />
    req.setEndpoint(&#8216;http://maps.google.com/maps/api/geocode/xml?address=torre+parquecristal+caracas+venezuela&amp;sensor=true&#8217;);<br />
    req.setMethod(&#8216;GET&#8217;);</p>
<p>     HTTPResponse resp = http.send(req);</p>
<p>    String json;</p>
<p>    json = resp.getBody().replace(&#8216;\n&#8217;, &#8221;);<br />
/*****</p>
<p>//***** XML received****</p>
<p> OK</p>
<p>  street_address<br />
  1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA</p>
<p>   1600<br />
   1600<br />
   street_number</p>
<p>   Amphitheatre Pkwy<br />
   Amphitheatre Pkwy<br />
   route</p>
<p>   Mountain View<br />
   Mountain View<br />
   locality<br />
   political</p>
<p>   San Jose<br />
   San Jose<br />
   administrative_area_level_3<br />
   political</p>
<p>   Santa Clara<br />
   Santa Clara<br />
   administrative_area_level_2<br />
   political</p>
<p>   California<br />
   CA<br />
   administrative_area_level_1<br />
   political</p>
<p>   United States<br />
   US<br />
   country<br />
   political</p>
<p>   94043<br />
   94043<br />
   postal_code</p>
<p>    37.4217550<br />
    -122.0846330</p>
<p>   ROOFTOP</p>
<p>     37.4188514<br />
     -122.0874526</p>
<p>     37.4251466<br />
     -122.0811574</p>
<p>         */</p>
<p>    JSONObject j = new JSONObject( json );</p>
<p>    JSONObject resp2;<br />
    /*<br />
    //*****First option *****<br />
    // I will change this section witht he correct data and fields after solve the error of semi colon.</p>
<p>    public String toDisplayString() {  /**  error message &#8220;Error de compilación: expecting a semi-colon, found &#8216;(&#8216; &#8221; after &#8220;toDisplayString&#8221;<br />
            return address + &#8216; ['<br />
            + coordinate1 + ', '<br />
            + coordinate2 + ', '<br />
            + coordinate3 + '] &#8211; Status: &#8216;<br />
            + statusCode;<br />
        }</p>
<p>      resp2 = (j).toDisplayString();</p>
<p>*/</p>
<p>/*<br />
//*****second option *****</p>
<p>    resp2 = j.getValues(&#8216;GeocodeResponse&#8217;); //**** Method does not exist or incorrect signature: [JSONObject].getValues(String</p>
<p>  */</p>
<p>      //check the response<br />
    if (resp.getStatusCode() == 200) {<br />
      System.debug(&#8216;Exitoso &#8216;+ resp);<br />
      Event acc = new Event(Id=&#8217;00U3000000AGFnJEAX&#8217;);<br />
      acc.Description = &#8216; Created &#8216;+datetime.now() ;<br />
      Update acc;</p>
<p>    } else {<br />
      System.debug(&#8216;Callout failed: &#8216; + resp);<br />
      Event acc = new Event(Id=&#8217;00U3000000AGFnJEAX&#8217;);<br />
      acc.Description = &#8216;Malo  fecha&#8217;+datetime.now() ;<br />
      update acc;</p>
<p>    } //else</p>
<p>    }//method</p>
<p>}//class</p>
<p>Best Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeffdonthemic</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-361</link>
		<dc:creator>jeffdonthemic</dc:creator>
		<pubDate>Wed, 06 Jan 2010 17:55:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-361</guid>
		<description>Awesome! I struggled with this for a couple of weeks and was getting obsessed with it. Glad it helped out.</description>
		<content:encoded><![CDATA[<p>Awesome! I struggled with this for a couple of weeks and was getting obsessed with it. Glad it helped out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Leach</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/comment-page-1/#comment-360</link>
		<dc:creator>Mike Leach</dc:creator>
		<pubDate>Wed, 06 Jan 2010 17:16:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953#comment-360</guid>
		<description>Very cool article Jeff (and timely too, as I&#039;m dealing with server-side Apex JSON parsing).

Thanks!</description>
		<content:encoded><![CDATA[<p>Very cool article Jeff (and timely too, as I&#8217;m dealing with server-side Apex JSON parsing).</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
