use of com.fasterxml.jackson.core.JsonGenerator in project Hystrix by Netflix.
the class HystrixConfigurationJsonStream method convertToString.
public static String convertToString(HystrixConfiguration config) throws IOException {
StringWriter jsonString = new StringWriter();
JsonGenerator json = jsonFactory.createGenerator(jsonString);
json.writeStartObject();
json.writeStringField("type", "HystrixConfig");
json.writeObjectFieldStart("commands");
for (Map.Entry<HystrixCommandKey, HystrixCommandConfiguration> entry : config.getCommandConfig().entrySet()) {
final HystrixCommandKey key = entry.getKey();
final HystrixCommandConfiguration commandConfig = entry.getValue();
writeCommandConfigJson(json, key, commandConfig);
}
json.writeEndObject();
json.writeObjectFieldStart("threadpools");
for (Map.Entry<HystrixThreadPoolKey, HystrixThreadPoolConfiguration> entry : config.getThreadPoolConfig().entrySet()) {
final HystrixThreadPoolKey threadPoolKey = entry.getKey();
final HystrixThreadPoolConfiguration threadPoolConfig = entry.getValue();
writeThreadPoolConfigJson(json, threadPoolKey, threadPoolConfig);
}
json.writeEndObject();
json.writeObjectFieldStart("collapsers");
for (Map.Entry<HystrixCollapserKey, HystrixCollapserConfiguration> entry : config.getCollapserConfig().entrySet()) {
final HystrixCollapserKey collapserKey = entry.getKey();
final HystrixCollapserConfiguration collapserConfig = entry.getValue();
writeCollapserConfigJson(json, collapserKey, collapserConfig);
}
json.writeEndObject();
json.writeEndObject();
json.close();
return jsonString.getBuffer().toString();
}
use of com.fasterxml.jackson.core.JsonGenerator in project Hystrix by Netflix.
the class SerialHystrixConfiguration method toJsonString.
public static String toJsonString(HystrixConfiguration config) {
StringWriter jsonString = new StringWriter();
try {
JsonGenerator json = jsonFactory.createGenerator(jsonString);
serializeConfiguration(config, json);
} catch (Exception e) {
throw new RuntimeException(e);
}
return jsonString.getBuffer().toString();
}
use of com.fasterxml.jackson.core.JsonGenerator in project Hystrix by Netflix.
the class SerialHystrixDashboardData method toJsonString.
public static String toJsonString(HystrixCollapserMetrics collapserMetrics) {
StringWriter jsonString = new StringWriter();
try {
JsonGenerator json = jsonFactory.createGenerator(jsonString);
writeCollapserMetrics(collapserMetrics, json);
json.close();
return jsonString.getBuffer().toString();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
use of com.fasterxml.jackson.core.JsonGenerator in project wiquery by WiQuery.
the class AutocompleteComponent method onBeforeRenderAutocomplete.
@Override
protected void onBeforeRenderAutocomplete(Autocomplete<?> autocomplete) {
StringWriter sw = new StringWriter();
try {
JsonGenerator gen = new JsonFactory().createGenerator(sw);
List<Object> json = new ArrayList<Object>();
T defaultValue = AutocompleteComponent.this.getModelObject();
AutocompleteJson value = null;
Integer index = 0;
for (T obj : AutocompleteComponent.this.list.getObject()) {
index++;
value = newAutocompleteJson(index, obj);
json.add(value);
if (obj.equals(defaultValue)) {
autocomplete.setDefaultModelObject(value.getLabel());
getAutocompleteHidden().setModelObject(value.getValueId());
}
}
new ObjectMapper().writeValue(gen, json);
} catch (IOException e) {
throw new WicketRuntimeException(e);
}
autocomplete.getOptions().put("source", sw.toString());
}
use of com.fasterxml.jackson.core.JsonGenerator in project pinpoint by naver.
the class MappingJackson2JsonpView method renderMergedOutputModel.
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
Object value = filterModel(model);
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(response.getOutputStream(), this.encoding);
if (this.prefixJson) {
generator.writeRaw("{} && ");
}
final String callBackParameter = getCallBackParameter(request);
if (StringUtils.isEmpty(callBackParameter)) {
this.objectMapper.writeValue(generator, value);
} else {
generator.writeRaw(callBackParameter);
generator.writeRaw(cbPrefix);
this.objectMapper.writeValue(generator, value);
generator.writeRaw(cbSuffix);
generator.writeRaw(cbEnd);
}
generator.flush();
}
Aggregations