Le 19/05/2016 09:23, chorem.org scm a écrit :
- String resultingJSON = "{\"uuid\":\"" + task.getName()+ "\",\"periods\":" + getTimesAndCommentsJSON(task, startDate, endDate) +"}"; + String resultingJSON = "{\"URL\":\"" + task.getSynchronisingURL()+ "\",\"periods\":" + getTimesAndCommentsJSON(task, startDate, endDate) +"}";
Tu devrais te trouver une petite dépendance qui de permettrais de generer le json de facon plus efficace et maintenable. Genre "json-simple", "gson" ou ... plein d'autre : http://www.json.org/ Ensuite, deux cas soit tu as un objet convertible en Java, soit tu n'en a pas (comme ici). Cela donnerais un code genre: JSONObject response = new JSONObject(); response.put("URL", task.getSynchronisingURL()); response.put("periods", getTimesAndCommentsJSON(task, startDate, endDate)); return response.toString(); C'est un peu plus facile que les concaténations de chaîne.