title: Iterating over a JSON array in scala
body: <p>I'm using the JSON lib net.sf.json(<a href="http://json-lib.sourceforge.net/apidocs/net/sf/json/package-summary.html" rel="nofollow">http://json-lib.sourceforge.net/apidocs/net/sf/json/package-summary.html</a>) in my scala code.
  Also, I'm using the specs BDD framework (<a href="http://code.google.com/p/specs/" rel="nofollow">http://code.google.com/p/specs/</a>) for unit testing. In the doBefore block, i have the following code:</p>
  
  <pre><code>doBefore {
    iter = serversJSON.iterator()
  }
  </code></pre>
  
  <p>serversJSON is a JSONArray object. Outside the doBefore block, I have declared the variables used as follows</p>
  
  <pre><code>var serversJSON:JSONArray = null
  var iter:Iterator[JSONArray] = null
  </code></pre>
  
  <p>But on compilation I'm getting the following error.</p>
  
  <blockquote>
    <p>error: type mismatch; found   :
    java.util.Iterator[?0] where type ?0
    required:
    java.util.Iterator[net.sf.json.JSONArray]
    iter = serversJSON.iterator()</p>
  </blockquote>
  
  <p>I guess the way i have declared the iter object outside doBefore is incorrect. How to fix this?</p>
  
  <p>Please Help
  Thank You.</p>