private void setLabels( JSONObject jObj, Object labels ) throws JSONException {
if (labels == null) return;
if ( !(labels instanceof List)){
throw new JSONException("xLabels is ignored, must be List<String> or List<Map>");
}
if (((List)labels).size() == 0) return;
Object testLabel = ((List)labels).get(0);
JSONArray labelArray = new JSONArray();
if (testLabel instanceof Map){
for(Map oneLabel : (List<Map>) labels ){
JSONObject labelObj = new JSONObject();
setJObjectStr(labelObj, "label", (String) oneLabel.get("label") );
setJObjectStr(labelObj, "value", (String) oneLabel.get("value") );
setJObjectStr(labelObj, "title", (String) oneLabel.get("title") );
labelArray.put(labelObj);
}
jObj.put("labels", labelArray);
}else
if (testLabel instanceof String){
for(String oneLabel : (List<String>) labels){
labelArray.put(oneLabel);
}
jObj.put("labels", labelArray);
}else{
throw new JSONException("xLabels is ignored, must be List<String> or List<Map>");
}
}