当前位置: 首页>>代码示例>>Java>>正文


Java SerializeFilter类代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializeFilter的典型用法代码示例。如果您正苦于以下问题:Java SerializeFilter类的具体用法?Java SerializeFilter怎么用?Java SerializeFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SerializeFilter类属于com.alibaba.fastjson.serializer包,在下文中一共展示了SerializeFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toJSONString

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public static final String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();
    try {
        JSONSerializer serializer = new JSONSerializer(out);
        for (SerializerFeature feature : features) {
            serializer.config(feature, true);
        }
        serializer.config(SerializerFeature.WriteDateUseDateFormat, true);
        setFilter(serializer, filter);
        serializer.write(object);
        String serializeWriter = out.toString();
        return serializeWriter;
    } finally {
        out.close();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:JSON.java

示例2: createSuccessResponse

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public static String createSuccessResponse(Integer httpCode, Object result, SerializerFeature serializerFeature, SerializeFilter filter, HttpServletResponse response){
		PrintWriter printWriter = null;
		String jsonString = "";
		try {
			response.setCharacterEncoding(RESPONSE_CHARACTERENCODING);
			response.setContentType(RESPONSE_CONTENTTYPE);
			response.setStatus(httpCode);
			printWriter = response.getWriter();
			if(null != result){
				if(null!=filter){
					jsonString = JSONObject.toJSONString(result,filter,serializerFeature);
				}else{
//					jsonString = JSONObject.toJSONString(result, serializerFeature);
					jsonString = JSONObject.toJSONStringWithDateFormat(result,"yyyy-MM-dd HH:ss:mm",serializerFeature);
				}
				printWriter.write(jsonString); 
			}
			printWriter.flush();

		} catch (Exception e) {
			log.error("createResponse failed", e);
		} finally {
			if(null!=printWriter)printWriter.close();
		}
		return jsonString;
	}
 
开发者ID:leon66666,项目名称:spring-boot-frameset,代码行数:27,代码来源:ServletUtil.java

示例3: test_enum

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public void test_enum() throws Exception {
    Model model = new Model();
    model.t1 = Type.A;
    model.t2 = null;
    
    ValueFilter valueFilter = new ValueFilter() {

        public Object process(Object object, String name, Object value) {
            return value;
        }
        
    };
    
    SerializeFilter[] filters = {valueFilter};
    String text = JSON.toJSONString(model, SerializeConfig.getGlobalInstance(), // 
                                    filters, 
                                    null,
                                    0, // 
                                    SerializerFeature.QuoteFieldNames, // 
                                    SerializerFeature.BrowserCompatible, // 
                                    SerializerFeature.WriteEnumUsingName);
    Assert.assertEquals("{\"t1\":\"A\"}", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:EnumFieldsTest8.java

示例4: setFilter

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
private static void setFilter(JSONSerializer serializer, SerializeFilter filter) {
    if (filter != null) {
        if (filter instanceof PropertyPreFilter) {
            serializer.getPropertyPreFilters().add((PropertyPreFilter) filter);
        }
        if (filter instanceof NameFilter) {
            serializer.getNameFilters().add((NameFilter) filter);
        }
        if (filter instanceof ValueFilter) {
            serializer.getValueFilters().add((ValueFilter) filter);
        }
        if (filter instanceof PropertyFilter) {
            serializer.getPropertyFilters().add((PropertyFilter) filter);
        }
        if (filter instanceof BeforeFilter) {
            serializer.getBeforeFilters().add((BeforeFilter) filter);
        }
        if (filter instanceof AfterFilter) {
            serializer.getAfterFilters().add((AfterFilter) filter);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:JSON.java

示例5: toJSONString

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public static final String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();

    try {
        JSONSerializer serializer = new JSONSerializer(out);
        for (com.alibaba.fastjson.serializer.SerializerFeature feature : features) {
            serializer.config(feature, true);
        }

        serializer.config(SerializerFeature.WriteDateUseDateFormat, true);

        setFilter(serializer, filter);

        serializer.write(object);

        return out.toString();
    } finally {
        out.close();
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:21,代码来源:JSON.java

示例6: addSerializeFilter

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
@Deprecated
public void addSerializeFilter(SerializeFilter filter) {
    if (filter == null) {
        return;
    }

    int length = this.fastJsonConfig.getSerializeFilters().length;
    SerializeFilter[] filters = new SerializeFilter[length + 1];
    System.arraycopy(this.fastJsonConfig.getSerializeFilters(), 0, filters, 0, length);
    filters[filters.length - 1] = filter;
    this.fastJsonConfig.setSerializeFilters(filters);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:FastJsonHttpMessageConverter.java

示例7: FastJsonConfig

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
/**
 * init param.
 */
public FastJsonConfig() {

    this.charset = Charset.forName("UTF-8");

    this.serializeConfig = SerializeConfig.getGlobalInstance();
    this.parserConfig = new ParserConfig();

    this.serializerFeatures = new SerializerFeature[] {
            SerializerFeature.BrowserSecure
    };

    this.serializeFilters = new SerializeFilter[0];
    this.features = new Feature[0];
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FastJsonConfig.java

示例8: test_context_value_filter_not_effected

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
@Test
public void test_context_value_filter_not_effected () {
    List<Object> params = new ArrayList<Object>();
    Map data = new HashMap();
    data.put("name", "ace");
    params.add(data);
    //fail Actual   :[{"name":"ace"}]
    Assert.assertEquals("[{\"name\":\"mark-ace\"}]", JSON.toJSONString(params,
                    new SerializeFilter[]{
                            contextValueFilter
                    })
    );

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:Issue1307.java

示例9: test_context_value_filter_effected

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
@Test
public void test_context_value_filter_effected() {
    List<Object> params = new ArrayList<Object>();
    Map data = new HashMap();
    data.put("name", "ace");
    params.add(data);
    //success
    Assert.assertEquals("[{\"name\":\"mark-ace\"}]", JSON.toJSONString(params,
                    new SerializeFilter[]{
                            contextValueFilter,
                            valueFilter
                    })
    );
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:Issue1307.java

示例10: test_for_issue

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public void test_for_issue() throws Exception {
    Map map = Collections.singletonMap("value", 123);

    String json = JSON.toJSONString(map
            , SerializeConfig.globalInstance
            , new SerializeFilter[0]
            , null
            , JSON.DEFAULT_GENERATE_FEATURE & ~SerializerFeature.QuoteFieldNames.mask
    );
    assertEquals("{value:123}", json);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:UnQuoteFieldNamesTest.java

示例11: test_for_bug

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public void test_for_bug() throws Exception {
    ContactTemplateParam param = new ContactTemplateParam();
    param.setAuditStatus(AuditStatusType.AUDIT_FAILURE);

    String json = JSON.toJSONString(param, new SerializeFilter[] { new IntEnumFilter("auditStatus") });
    assertEquals("{\"auditStatus\":0}", json);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Bug_for_xujin2.java

示例12: test_for_issue

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public void test_for_issue() throws Exception {
    VO vo = new VO();
    
    SerializeFilter filter = null;
    JSON.toJSONString(vo, SerializeConfig.getGlobalInstance(), filter);
    JSON.toJSONString(vo, SerializeConfig.getGlobalInstance(), new SerializeFilter[0]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Issue204.java

示例13: thin

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public String thin(Object bean) {
    toJSONString(bean, new SerializeFilter[]{firstValueFilter});
    val ret = toJSONString(bean,
            new SerializeFilter[]{nameFilter, secondValueFilter},
            WriteMapNullValue);

    this.keyMapping = WestJsonUtils.invert(innerKeyMapping);
    this.valueMapping = WestJsonUtils.invert(innerValueMapping);

    return ret;
}
 
开发者ID:bingoohuang,项目名称:westjson,代码行数:12,代码来源:WestJsonThiner.java

示例14: setFilter

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
private static void setFilter(JSONSerializer serializer, SerializeFilter filter) {
    if (filter == null) {
        return;
    }
    
    if (filter instanceof PropertyPreFilter) {
        serializer.getPropertyPreFilters().add((PropertyPreFilter) filter);
    }

    if (filter instanceof NameFilter) {
        serializer.getNameFilters().add((NameFilter) filter);
    }

    if (filter instanceof ValueFilter) {
        serializer.getValueFilters().add((ValueFilter) filter);
    }

    if (filter instanceof PropertyFilter) {
        serializer.getPropertyFilters().add((PropertyFilter) filter);
    }

    if (filter instanceof BeforeFilter) {
        serializer.getBeforeFilters().add((BeforeFilter) filter);
    }

    if (filter instanceof AfterFilter) {
        serializer.getAfterFilters().add((AfterFilter) filter);
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:30,代码来源:JSON.java

示例15: fastjsonFilters

import com.alibaba.fastjson.serializer.SerializeFilter; //导入依赖的package包/类
public SerializeFilter[] fastjsonFilters() {
    if (null == fastjsonFilters) {
        return null;
    }
    int len = fastjsonFilters.length;
    SerializeFilter[] filters = new SerializeFilter[len];
    for (int i = 0; i < len; ++i) {
        filters[i] = app().getInstance(fastjsonFilters[i]);
    }
    return filters;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:ActContext.java


注:本文中的com.alibaba.fastjson.serializer.SerializeFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。