1

I'm using the JSON lib net.sf.json(http://json-lib.sourceforge.net/apidocs/net/sf/json/package-summary.html) in my scala code. Also, I'm using the specs BDD framework (http://code.google.com/p/specs/) for unit testing. In the doBefore block, i have the following code:

doBefore {
  iter = serversJSON.iterator()
}

serversJSON is a JSONArray object. Outside the doBefore block, I have declared the variables used as follows

var serversJSON:JSONArray = null
var iter:Iterator[JSONArray] = null

But on compilation I'm getting the following error.

error: type mismatch; found : java.util.Iterator[?0] where type ?0 required: java.util.Iterator[net.sf.json.JSONArray] iter = serversJSON.iterator()

I guess the way i have declared the iter object outside doBefore is incorrect. How to fix this?

Please Help Thank You.

1 Answer 1

4

As indicated here, the JSON library's iterator method returns a raw Iterator, not an Iterator[JSONArray]. You'll want to declare it as follows:

var serversJSON:JSONArray = null
var iter:Iterator[_] = null
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.