本文整理汇总了Java中org.boon.json.JsonSerializerFactory类的典型用法代码示例。如果您正苦于以下问题:Java JsonSerializerFactory类的具体用法?Java JsonSerializerFactory怎么用?Java JsonSerializerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonSerializerFactory类属于org.boon.json包,在下文中一共展示了JsonSerializerFactory类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: JsonBoon
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public JsonBoon() {
JsonParserFactory jsonParserFactory = new JsonParserFactory();
jsonParserFactory.lax();
// Include nulls and empty fields
JsonSerializerFactory serializerFactory = new JsonSerializerFactory();
serializerFactory.setIncludeNulls(true);
serializerFactory.setIncludeEmpty(true);
// Install MongoDB / BSON serializers
tryToAddSerializers("io.datatree.dom.adapters.JsonBoonBsonSerializers", serializerFactory);
// Format dates
serializerFactory.setJsonFormatForDates(Config.USE_TIMESTAMPS);
mapper = JsonFactory.create(jsonParserFactory, serializerFactory);
}
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:18,代码来源:JsonBoon.java
示例2: addSerializer
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public static final <T> void addSerializer(JsonSerializerFactory factory, Class<T> type,
CheckedBiConsumer<T, CharBuf> consumer) {
factory.addTypeSerializer(type, new CustomObjectSerializer<T>() {
@Override
public Class<T> type() {
return type;
}
@Override
public void serializeObject(JsonSerializerInternal serializer, T instance, CharBuf builder) {
try {
consumer.accept(instance, builder);
} catch (IOException cause) {
throw new IllegalArgumentException(cause);
}
}
});
}
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:21,代码来源:JsonBoon.java
示例3: toJsonString
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public static <T> String toJsonString(T document) {
JsonSerializerFactory serializer = new JsonSerializerFactory().addFilter(new FieldFilter() {
@Override
public boolean include(Object o, FieldAccess fieldAccess) {
if ( fieldAccess.hasAnnotation(DocumentRef.class.getName())) {
return false;
}
return true;
}
});
ObjectMapper mapper = JsonFactory.create(null, serializer);
return mapper.toJson(document);
}
开发者ID:wmira,项目名称:nosql-jdbc,代码行数:19,代码来源:PgsqlJsonRepository.java
示例4: createJsonSerializerFactory
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public static JsonSerializerFactory createJsonSerializerFactory(final boolean outputType, final String fieldAccessType,
final boolean includeNulls, final boolean useAnnotations, final boolean includeEmpty, final boolean jsonFormatForDates,
final boolean handleComplexBackReference, final boolean handleSimpleBackReference, final boolean includeDefault,
final boolean cacheInstances, final String view) {
final JsonSerializerFactory jsonSerializerFactory = new JsonSerializerFactory();
if (FieldAccessMode.FIELD.name().equals(fieldAccessType)) {
jsonSerializerFactory.useFieldsOnly();
} else if (FieldAccessMode.PROPERTY.name().equals(fieldAccessType)) {
jsonSerializerFactory.usePropertyOnly();
} else if (FieldAccessMode.FIELD_THEN_PROPERTY.name().equals(fieldAccessType)) {
jsonSerializerFactory.isUseFieldsFirst();
} else if (FieldAccessMode.PROPERTY_THEN_FIELD.name().equals(fieldAccessType)) {
jsonSerializerFactory.usePropertyOnly();
}
jsonSerializerFactory.setOutputType(outputType);
jsonSerializerFactory.setIncludeNulls(includeNulls);
jsonSerializerFactory.setUseAnnotations(useAnnotations);
jsonSerializerFactory.setIncludeEmpty(includeEmpty);
jsonSerializerFactory.setJsonFormatForDates(jsonFormatForDates);
jsonSerializerFactory.setHandleComplexBackReference(handleComplexBackReference);
jsonSerializerFactory.setHandleSimpleBackReference(handleSimpleBackReference);
jsonSerializerFactory.setIncludeDefault(includeDefault);
jsonSerializerFactory.setCacheInstances(cacheInstances);
jsonSerializerFactory.setView(view);
return jsonSerializerFactory;
}
开发者ID:rmannibucau,项目名称:boon-jaxrs-provider,代码行数:27,代码来源:Boons.java
示例5: setLoggingEventAttribute
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
/**
* Set the attribute of a logging event
*/
public static final LoggingEvent setLoggingEventAttribute(LoggingEvent event, String name, Object value) {
event = ensureLoggingEvent(event);
if (null != name && null != value) {
JsonSerializer ser = new JsonSerializerFactory().create();
event.putToAttributes(name, ser.serialize(value).toString());
}
return event;
}
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:15,代码来源:LogUtil.java
示例6: addHttpHeaders
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public static final LoggingEvent addHttpHeaders(LoggingEvent event, HttpServletRequest req) {
event = ensureLoggingEvent(event);
//
// Add request headers
//
Map<String,Object> headerMap = new HashMap<String,Object>();
Enumeration<String> headerNames = req.getHeaderNames();
while(headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
Enumeration<String> values = req.getHeaders(name);
List<String> hdrs = new ArrayList<String>();
while(values.hasMoreElements()) {
hdrs.add(values.nextElement());
}
if (!hdrs.isEmpty()) {
headerMap.put(name, hdrs);
}
}
if (!headerMap.isEmpty()) {
JsonSerializer ser = new JsonSerializerFactory().create();
event.putToAttributes(LogUtil.HTTP_HEADERS, ser.serialize(headerMap).toString());
}
return event;
}
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:33,代码来源:LogUtil.java
示例7: factory
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
private JsonSerializerFactory factory() {
JsonSerializerFactory value = factory.get();
if (value == null) {
synchronized (factory) {
value = factory.get();
if (value == null) {
value = Boons.createJsonSerializerFactory(outputType, fieldAccessType, includeNulls, useAnnotations, includeEmpty, jsonFormatForDates, handleComplexBackReference, handleSimpleBackReference, includeDefault, cacheInstances, view);
factory.set(value);
}
}
}
return value;
}
开发者ID:rmannibucau,项目名称:boon-jaxrs-provider,代码行数:14,代码来源:BoonJsonMessageBodyWriter.java
示例8: init
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
protected void init(final JsonSerializerFactory factory) {
if (factory != null) {
this.factory.set(factory);
} else {
factory(); // force init
}
}
开发者ID:rmannibucau,项目名称:boon-jaxrs-provider,代码行数:8,代码来源:BoonJsonMessageBodyWriter.java
示例9: testFlatten1
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
@Test
public void testFlatten1()
{
ClassLoader classLoader = getClass().getClassLoader();
URL url = classLoader.getResource("example1.json");
String path = url.getFile();
File file = new File(path);
ValueMap jsonObject = (ValueMap)new JsonSlurper().parse(file);
ValueList results = (ValueList)jsonObject.get("results");
JsonSerializer jsonSerializer = new JsonSerializerFactory().outputType().create();
System.out.println(jsonSerializer.serialize(jsonObject));
}
开发者ID:jdbc-json,项目名称:jdbc-cb,代码行数:19,代码来源:TestBoon.java
示例10: setLoggingEventStackTrace
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
public static final LoggingEvent setLoggingEventStackTrace(LoggingEvent event, String name, Throwable t) {
event = ensureLoggingEvent(event);
if (null == t) {
return event;
}
// Fill the stack trace
Object[][] stacktrace = null;
int offset = 0;
while(null != t) {
if (null == t.getStackTrace()) {
t.fillInStackTrace();
}
StackTraceElement[] ste = t.getStackTrace();
if (null == stacktrace) {
stacktrace = new Object[ste.length + 1][];
} else {
Object[][] oldtrace = stacktrace;
// Resize stacktrace
stacktrace = new Object[stacktrace.length + ste.length + 1][];
System.arraycopy(oldtrace, 0, stacktrace, 0, oldtrace.length);
offset = oldtrace.length;
}
// Fill message
stacktrace[offset] = new Object[4];
stacktrace[offset][0] = "";
stacktrace[offset][1] = 0;
stacktrace[offset][2] = t.getClass().getName();
stacktrace[offset][3] = null != t.getMessage() ? t.getMessage() : "";
offset++;
for (int i = 0; i < ste.length; i++) {
stacktrace[offset+i] = new Object[4];
stacktrace[offset+i][0] = ste[i].getFileName();
stacktrace[offset+i][1] = ste[i].getLineNumber();
stacktrace[offset+i][2] = ste[i].getClassName();
stacktrace[offset+i][3] = ste[i].getMethodName();
}
t = t.getCause();
}
if (null == event) {
event = new LoggingEvent();
}
JsonSerializer ser = new JsonSerializerFactory().create();
event.putToAttributes(name, ser.serialize(stacktrace).toString());
return event;
}
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:63,代码来源:LogUtil.java
示例11: prepare
import org.boon.json.JsonSerializerFactory; //导入依赖的package包/类
@Setup
public void prepare() {
this.serializer = new JsonSerializerFactory().setSerializeAsSupport(false).useFieldsOnly().create();
}
开发者ID:taichi,项目名称:json-benchmarks,代码行数:5,代码来源:BoonBenchmark.java
注:本文中的org.boon.json.JsonSerializerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论