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


Java JsonIgnoreProperties類代碼示例

本文整理匯總了Java中org.codehaus.jackson.annotate.JsonIgnoreProperties的典型用法代碼示例。如果您正苦於以下問題:Java JsonIgnoreProperties類的具體用法?Java JsonIgnoreProperties怎麽用?Java JsonIgnoreProperties使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonIgnoreProperties類屬於org.codehaus.jackson.annotate包,在下文中一共展示了JsonIgnoreProperties類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findIgnoreUnknownProperties

import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
public Boolean findIgnoreUnknownProperties(AnnotatedClass paramAnnotatedClass)
{
  JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class);
  if (localJsonIgnoreProperties == null)
    return null;
  return Boolean.valueOf(localJsonIgnoreProperties.ignoreUnknown());
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:8,代碼來源:JacksonAnnotationIntrospector.java

示例2: findPropertiesToIgnore

import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
public String[] findPropertiesToIgnore(AnnotatedClass paramAnnotatedClass)
{
  JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class);
  if (localJsonIgnoreProperties == null)
    return null;
  return localJsonIgnoreProperties.value();
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:8,代碼來源:JacksonAnnotationIntrospector.java

示例3: createMixInAnnotation

import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
/**
 * 創建jackson的代理注解接口類 <br>
 * 2013-10-25 上午11:59:50
 *
 * @param names 要生成的字段
 * @return 代理接口類
 */
private Class<?> createMixInAnnotation(String[] names) {
    Class<?> clazz = null;
    clazz = proxyMixInAnnotationMap.get(StringHelper.hashCodeOfStringArray(names));
    if (clazz != null) {
        return clazz;
    }

    ClassPool pool = ClassPool.getDefault();

    // 創建代理接口
    CtClass cc = pool.makeInterface("ProxyMixInAnnotation" + System.currentTimeMillis()
            + proxyIndex++);

    ClassFile ccFile = cc.getClassFile();
    ConstPool constpool = ccFile.getConstPool();

    // create the annotation
    AnnotationsAttribute attr = new AnnotationsAttribute(constpool,
            AnnotationsAttribute.visibleTag);
    // 創建JsonIgnoreProperties注解
    Annotation jsonIgnorePropertiesAnnotation = new Annotation(
            JsonIgnoreProperties.class.getName(), constpool);

    BooleanMemberValue ignoreUnknownMemberValue = new BooleanMemberValue(false, constpool);

    ArrayMemberValue arrayMemberValue = new ArrayMemberValue(constpool);// value的數組成員

    Collection<MemberValue> memberValues = new HashSet<MemberValue>();
    for (int i = 0; i < names.length; i++) {
        String name = names[i];
        StringMemberValue memberValue = new StringMemberValue(constpool);// 將name值設入注解內
        memberValue.setValue(name);
        memberValues.add(memberValue);
    }
    arrayMemberValue.setValue(memberValues.toArray(new MemberValue[]{}));

    jsonIgnorePropertiesAnnotation.addMemberValue("value", arrayMemberValue);
    jsonIgnorePropertiesAnnotation.addMemberValue("ignoreUnknown", ignoreUnknownMemberValue);

    attr.addAnnotation(jsonIgnorePropertiesAnnotation);
    ccFile.addAttribute(attr);

    // generate the class
    try {
        clazz = cc.toClass();
        proxyMixInAnnotationMap.put(StringHelper.hashCodeOfStringArray(names), clazz);
        // JsonIgnoreProperties ignoreProperties = (JsonIgnoreProperties)
        // clazz
        // .getAnnotation(JsonIgnoreProperties.class);

        // EntityHelper.print(ignoreProperties);
        //
        // EntityHelper.print(clazz);

        // try {
        // Object instance = clazz.newInstance();
        // EntityHelper.print(instance);
        //
        // } catch (InstantiationException e) {
        // e.printStackTrace();
        // } catch (IllegalAccessException e) {
        // e.printStackTrace();
        // }
    } catch (CannotCompileException e) {
        e.printStackTrace();
    }

    // right
    // mthd.getMethodInfo().addAttribute(attr);

    return clazz;

}
 
開發者ID:blademainer,項目名稱:common_utils,代碼行數:81,代碼來源:Jackson1JavassistFilterPropertyHandler.java


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