2016-04-25 87 views
0

我想抓住一个JSON对象的十六进制值,但继续得到错误构造函数JSONobject(对象)不可见。我正在使用处理版本2.1。构造函数JSONobject(对象)不可见

String baseURL = "http://www.colr.org/json/tag/"; 
String[] keyword = {"county"}; 

void setup(){ 
getColor(); 
}; 

void draw(){ 
}; 

void getColor(){ 
    for (int i = 0; i < keyword.length; i++){ 
    String request = baseURL + keyword[i]; 

    try{ 
    JSONObject colorData = new JSONObject(join(loadStrings(request),"")); 
    JSONArray results = colorData.getJSONArray("results"); 
    } 
    catch(JSONException e){ 
     println("error"); 
    }; 
    }; 
}; 

回答

0

错误说明了一切:你不能使用该构造。

您应该只使用loadJSONObject()函数。您可以直接给它的URL,而不是通过调用loadStrings(),然后join()额外的步骤去(这是一个有点迂回的方式来读取String反正):

JSONObject colorData = loadJSONObject(request); 

更多信息可在找到。

相关问题