1
我想知道是否有辦法從JSONObject中獲取Vector。比方說,我有這個:從JSONObject獲取矢量對象
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」,但不知道如何正確訪問它並添加到該Vector。
我是一個初學者這樣下去容易對我:)