本文整理匯總了Java中com.addthis.codec.jackson.Jackson類的典型用法代碼示例。如果您正苦於以下問題:Java Jackson類的具體用法?Java Jackson怎麽用?Java Jackson使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Jackson類屬於com.addthis.codec.jackson包,在下文中一共展示了Jackson類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tryEncodeString
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static String tryEncodeString(Object object, String defaultValue) {
try {
return Jackson.defaultCodec().getObjectMapper().writeValueAsString(object);
} catch (JsonProcessingException ex) {
return defaultValue;
}
}
示例2: dontError
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Test
public void dontError() throws IOException {
CodecJackson codecJackson = Jackson.defaultCodec();
ExecutorService service =
codecJackson.decodeObject(ExecutorService.class,
"thread-factory {nameFormat = ianRules}, core-threads = 2," +
"max-threads = 5, keep-alive = 0, queue-size = 100");
log.debug("service {}", service);
}
示例3: concreteValue
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Test
public void concreteValue() throws Exception {
ConfigValue greet = parseString("val = hi friend").getValue("val");
Greeter greeterObject = Jackson.defaultCodec().decodeObject(ParseGreetSub.class, greet);
String expected = "extra hi friend other Hello Worldnull bytes: 0 millis: 0";
assertEquals(expected, greeterObject.greet());
}
示例4: getValue
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Nullable @Override public T getValue(Bundle bundle) {
ValueObject valueObject = field.getValue(bundle);
if (valueObject == null) {
return null;
}
return Jackson.defaultMapper().convertValue(valueObject.asNative(), type);
}
示例5: createDerivedTyped
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Test
public void createDerivedTyped() throws IOException {
DerivedTypedField<List<String>> autoField =
Jackson.defaultMapper().readValue("\"someField\"", new TypeReference<DerivedTypedField<List<String>>>() {});
Bundle bundle = Bundles.decode("someField: [a, b, c]");
List<String> strings = autoField.getValue(bundle);
assertEquals(Lists.newArrayList("a", "b", "c"), strings);
}
示例6: encode
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Override
public byte[] encode(Object obj) throws Exception {
return Jackson.defaultCodec().getObjectMapper().writeValueAsBytes(obj);
}
示例7: decode
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Override
public <T> T decode(T shell, byte[] data) throws IOException {
return Jackson.defaultCodec().getObjectMapper().readerForUpdating(shell).readValue(data);
}
示例8: encodeJsonNode
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static JsonNode encodeJsonNode(Object object) throws Exception {
return Jackson.defaultCodec().getObjectMapper().valueToTree(object);
}
示例9: encodeJSON
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
/** @deprecated Use {@link #encodeJsonNode(Object)} or {@link CodecJackson} */
@Deprecated
public static JSONObject encodeJSON(Object object) throws Exception {
return new JSONObject(Jackson.defaultCodec().getObjectMapper().writeValueAsString(object));
}
示例10: encodeString
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static String encodeString(Object object) throws JsonProcessingException {
return Jackson.defaultCodec().getObjectMapper().writeValueAsString(object);
}
示例11: decodeString
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
/** @deprecated Use {@link #decodeString(Class, String)} instead. */
@Deprecated
public static <T> T decodeString(T object, String json) throws IOException {
return Jackson.defaultCodec().getObjectMapper().readerForUpdating(object).readValue(json);
}
示例12: decodeJSON
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static <T> T decodeJSON(T object, JsonNode json) throws IOException {
return Jackson.defaultCodec().getObjectMapper().readerForUpdating(object).readValue(json);
}
示例13: newDefault
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
/** Construct an object of the requested plugin category based on the default type and values */
public static <T> T newDefault(@Nonnull String category) throws IOException {
return Jackson.defaultCodec().newDefault(category);
}
示例14: getCodec
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Override public Codec getCodec() {
Jackson.defaultCodec().getObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
return CodecJSON.INSTANCE;
}
示例15: genericAutocollection
import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Test
public void genericAutocollection() throws Exception {
GenericGreet<List<String>> gg = Jackson.defaultMapper().readValue("\"yolo\"", new TypeReference<GenericGreet<List<String>>>() {});
assertEquals(Lists.newArrayList("yolo"), gg.value);
}