/** * Converts object to a "simple" json. * * @param tag object tag. * @param object object to convert. * @param writer object writer. * @return object String representation. * @throws RedmineInternalError if conversion fails. */ public static <T> String toSimpleJSON(String tag, T object, JsonObjectWriter<T> writer) throws RedmineInternalError { final StringWriter swriter = new StringWriter(); final JSONWriter jsWriter = new JSONWriter(swriter); try { jsWriter.object(); jsWriter.key(tag); jsWriter.object(); writer.write(jsWriter, object); jsWriter.endObject(); jsWriter.endObject(); } catch (JSONException e) { throw new RedmineInternalError("Unexpected JSONException", e); } return swriter.toString(); }