Java Code Examples for net.sf.json.JsonConfig#setIgnoreDefaultExcludes()

The following examples show how to use net.sf.json.JsonConfig#setIgnoreDefaultExcludes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonUtil.java    From JavaEE-SSH-Template with MIT License 5 votes vote down vote up
public static JSONObject jsonFilter(Object obj, String[] filterNames){
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.setIgnoreDefaultExcludes(false);    
    jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);    //防止自包含
     
    if(filterNames != null){
        //这里是核心,过滤掉不想使用的属性
        jsonConfig .setExcludes(filterNames) ;
    }
    JSONObject jsonObj = JSONObject.fromObject(obj, jsonConfig);
    return jsonObj;
     
}
 
Example 2
Source File: JsonUtil.java    From JavaEE-SSH-Template with MIT License 5 votes vote down vote up
public static JSONArray jsonListFilter(List objList, String[] filterNames){
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.setIgnoreDefaultExcludes(false);    
    jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);    //防止自包含
     
    if(filterNames != null){
        //这里是核心,过滤掉不想使用的属性
        jsonConfig .setExcludes(filterNames) ;
    }
    JSONArray jsonArray = JSONArray.fromObject(objList, jsonConfig);
    return jsonArray;
     
}
 
Example 3
Source File: JsonUtil.java    From SmartEducation with Apache License 2.0 5 votes vote down vote up
public static JSONObject jsonFilter(Object obj, String[] filterNames){
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.setIgnoreDefaultExcludes(false);    
    jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);    //防止自包含
    
    if(filterNames != null){
        //这里是核心,过滤掉不想使用的属性
        jsonConfig .setExcludes(filterNames) ;
    }
    JSONObject jsonObj = JSONObject.fromObject(obj, jsonConfig);
    return jsonObj;
}
 
Example 4
Source File: JsonUtil.java    From SmartEducation with Apache License 2.0 5 votes vote down vote up
public static JSONArray jsonListFilter(List objList, String[] filterNames){
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.setIgnoreDefaultExcludes(false);    
    jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);    //防止自包含 
    //jsonConfig.registerJsonValueProcessor(java.sql.Timestamp.class, new DateJsonValueProcessor("yyyy-MM-dd HH:mm:ss")); 
    if(filterNames != null){
        //这里是核心,过滤掉不想使用的属性
        jsonConfig .setExcludes(filterNames) ;
    }
    JSONArray jsonArray = JSONArray.fromObject(objList, jsonConfig);
    return jsonArray;
}