public class Main {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
JSONObject object = new JSONObject();
object.put("name", "Walter");
object.put("age", 20);
object.put("job", "gamer");
try{
FileWriter file = new FileWriter("mydata.json");
file.write(object.toJSONString());
file.flush();
file.close();
}catch (Exception e){
e.getStackTrace();
}
}
}
mydata.json is in the same folder as Main class. Nothing happens.
If this library isn't good, recommend another one please.