Skip to content

Instantly share code, notes, and snippets.

@Neurogami
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neurogami/9080100 to your computer and use it in GitHub Desktop.
Save Neurogami/9080100 to your computer and use it in GitHub Desktop.
class Config {
JSONObject json;
Config(String cfgFile) {
json = loadJSONObject(cfgFile);
}
String getValue(String k) { return json.getString(k); }
String getString(String k) { return json.getString(k); }
int getInt(String k) { return json.getInt(k); }
float getFloat(String k) { return json.getFloat(k); }
boolean getBoolean(String k) { return json.getBoolean(k); }
String[] getStrings(String k) {
JSONArray values = json.getJSONArray(k);
String[] strings = new String[values.size()];
for (int i = 0; i < values.size(); i++) {
strings[i] = values.getString(i);
}
return strings;
}
int[] getInts(String k) {
JSONArray values = json.getJSONArray(k);
int[] ints = new int[values.size()];
for (int i = 0; i < values.size(); i++) {
ints[i] = values.getInt(i);
}
return ints;
}
float[] getFloats(String k) {
JSONArray values = json.getJSONArray(k);
float[] floats = new float[values.size()];
for (int i = 0; i < values.size(); i++) {
floats[i] = values.getFloat(i);
}
return floats;
}
boolean[] getBooleans(String k) {
JSONArray values = json.getJSONArray(k);
boolean[] booleans= new float[values.size()];
for (int i = 0; i < values.size(); i++) {
floats[i] = values.getBoolean(i);
}
return booleans;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment