public static void writeJSON(String filePath, JSONObject json) {
		try {
			File f = new File(filePath);

			// if the directory above the file doesn't exist, make it. :)
			File dir = f.getParentFile();
			if (!dir.exists()) {
				dir.mkdirs();
			}

			// delete the file if it exists already to completely overwrite
			if (f.exists()) {
				f.delete();
				f.createNewFile();
			}

			f.setWritable(true);

			FileWriter fileWrite = new FileWriter(f);
			fileWrite.write(json.toString());
			fileWrite.close();

		} catch (IOException e) {
			System.out
					.println("JSONObject: writeJson: could not write to file");
			e.printStackTrace();
		}
	}