我想知道是否有办法从 JSONObject 中获取 Vector。假设我有这个:
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 给我一个警告说未经检查的类型转换。是否可以从 JSONObject 获取某种类型的对象,然后能够使用该对象?我想向该 Vector 添加“goo”,但不确定如何正确访问它并添加到它。
我是初学者,所以请放轻松:)