I am trying to consume my newly setup RESTful WCF service, located at

[http://196.34.92.60/api/api/v1/public.svc/getoperators]

I accessed it using some third party tools, which I grabbed from

http://code.google.com/a/eclipselabs.org/p/restclient-tool/

https://addons.mozilla.org/en-US/firefox/addon/restclient/

and my results look like I expected:

{
   "Results":
   [
       "golden arrow",
       "jammie",
       "myciti"
   ]
}


All fine and well.  When I just type the url into my web browser, the response is

&lt;ResultList xmlns="http://schemas.datacontract.org/2004/07/Developer_Portal"xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;Results xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt;&lt;a:string&gt;golden arrow&lt;/a:string&gt;&lt;a:string&gt;jammie&lt;/a:string&gt;&lt;a:string&gt;myciti&lt;/a:string&gt;&lt;/Results&gt;&lt;/ResultList&gt;


Not what I expected, but I assumed  this was normal, and tried to comsume service in Javascript (here is fiddle)

http://jsfiddle.net/JmTe4/11/

It responds with an error.  At this point I'm stumped: what do I need to do to get the desired response in javascript?


Question: How to count the array from specific JSON object value?
Answer: There's still a typo in your JSON: you've got two commas in a row between the first two "bulan":"6" objects. But assuming you fix that...

If you're asking how to count distinct types for a particular bulan value you can do something like this:

function countTypesForBulan(resultArray, bulanVal) {
   var i,
       types,
       count = 0;
   for (i=0, types = {}; i &lt; resultArray.length; i++)
      if (resultArray[i].bulan === bulanVal &amp;&amp; !types[resultArray[i].type]) {
         types[resultArray[i].type] = true;
         count++;
      }
   return count;
}

console.log( countTypesForBulan(obj.GetReportIdResult, "4") );  // logs 3


The above loops through the array looking for a particular bulan value, and when it finds one it checks if it has already seen the associated type - if not, it adds it to the types object and increments the counter.

Demo: http://jsfiddle.net/pAWrT/