當前位置: 首頁>>代碼示例>>Java>>正文


Java Jackson類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:8,代碼來源:CodecJSON.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:10,代碼來源:ExecutorServiceBuilderTest.java

示例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());
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:8,代碼來源:FeatureTest.java

示例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);
}
 
開發者ID:addthis,項目名稱:bundle,代碼行數:8,代碼來源:DerivedTypedField.java

示例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);
}
 
開發者ID:addthis,項目名稱:bundle,代碼行數:9,代碼來源:AutoFieldTest.java

示例6: encode

import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
@Override
public byte[] encode(Object obj) throws Exception {
    return Jackson.defaultCodec().getObjectMapper().writeValueAsBytes(obj);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:5,代碼來源:CodecJSON.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:5,代碼來源:CodecJSON.java

示例8: encodeJsonNode

import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static JsonNode encodeJsonNode(Object object) throws Exception {
    return Jackson.defaultCodec().getObjectMapper().valueToTree(object);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:4,代碼來源:CodecJSON.java

示例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));
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:6,代碼來源:CodecJSON.java

示例10: encodeString

import com.addthis.codec.jackson.Jackson; //導入依賴的package包/類
public static String encodeString(Object object) throws JsonProcessingException {
    return Jackson.defaultCodec().getObjectMapper().writeValueAsString(object);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:4,代碼來源:CodecJSON.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:6,代碼來源:CodecJSON.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:4,代碼來源:CodecJSON.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:5,代碼來源:Configs.java

示例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;
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:5,代碼來源:CodecJsonBasicTest.java

示例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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:6,代碼來源:FeatureTest.java


注:本文中的com.addthis.codec.jackson.Jackson類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。