Skip to content

Instantly share code, notes, and snippets.

@Neurogami Neurogami/Config.pde
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.