I am wondering if there is a way to get a Vector from out of a JSONObject. Let’s say I have this :
public class Foo
private JSONObject json;
public Foo(){
try{
json=new JSONObject();
Vector<,F> v=new Vector<,F>(); // pretend like the comma isn't there please
json.put("blah", v); ...} catch (JSONException e){...}
}
.
.
.
public void addBlahs(,F goo){
try{
Object o=json.get("blah");
// Since json.get("blah") should be a Vector of .F's, I thought I could do something like this...
Vector<,F> v=(Vector <,F>) o;
v.add(goo);} catch (JSONException{ ...}
}
Eclipse gives me a warning saying unchecked type cast. Is it possible to get a certain type of object from a JSONObject and then be able to use that object? I want to add “goo”s to that Vector, but not sure how to properly access it and add to it.
I’m a beginner so go easy on me 🙂
You can’t put a
Vectorin aJSONObject. According to the documentation ofJSONObject#put(String, Object):However, you can use an
JSONArrayinstead.