use of net.sf.json.JsonConfig in project lobcder by skoulouzis.
the class PropPatchJsonResource method sendContent.
public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException {
log.debug("sendContent");
JsonConfig cfg = new JsonConfig();
cfg.setIgnoreTransientFields(true);
cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
List<FieldError> errors = new ArrayList<FieldError>();
if (resp != null && resp.getErrorProperties() != null) {
log.debug("error props: " + resp.getErrorProperties().size());
for (Status stat : resp.getErrorProperties().keySet()) {
List<NameAndError> props = resp.getErrorProperties().get(stat);
for (NameAndError ne : props) {
errors.add(new FieldError(ne.getName().getLocalPart(), ne.getError(), stat.code));
}
}
}
log.debug("errors size: " + errors.size());
FieldError[] arr = new FieldError[errors.size()];
arr = errors.toArray(arr);
Writer writer = new PrintWriter(out);
JSON json = JSONSerializer.toJSON(arr, cfg);
json.write(writer);
writer.flush();
}
use of net.sf.json.JsonConfig in project lobcder by skoulouzis.
the class PutJsonResource method sendContent.
/**
* Returns a JSON representation of the newly created hrefs
*
* @param out
* @param range
* @param params
* @param contentType
* @throws IOException
* @throws NotAuthorizedException
*/
@Override
public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException {
JsonConfig cfg = new JsonConfig();
cfg.setIgnoreTransientFields(true);
cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
NewFile[] arr;
if (newFiles != null) {
arr = new NewFile[newFiles.size()];
newFiles.toArray(arr);
} else {
arr = new NewFile[0];
}
Writer writer = new PrintWriter(out);
JSON json = JSONSerializer.toJSON(arr, cfg);
json.write(writer);
writer.flush();
}
use of net.sf.json.JsonConfig in project lobcder by skoulouzis.
the class JsonWriter method write.
public void write(Object object, OutputStream out) throws IOException {
JsonConfig cfg = new JsonConfig();
cfg.setIgnoreTransientFields(true);
cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
JSON json = JSONSerializer.toJSON(object, cfg);
Writer writer = new PrintWriter(out);
json.write(writer);
writer.flush();
}
Aggregations