Package net.sf.json.util

Examples of net.sf.json.util.PropertyFilter


    filteExcludes(bean, jsonConfig);
    return jsonConfig;
  }

  public static void filteExcludes(Object bean, JsonConfig jsonConfig) {
    jsonConfig.setJsonPropertyFilter(new PropertyFilter(){
      @Override
      public boolean apply(Object source, String name, Object value) {
        if(value == null)
          return true;
        try {
View Full Code Here


      // 注册日期解析器
      config.registerJsonValueProcessor(java.sql.Date.class, new JsonDateToStringProcessorImpl());
      config.registerJsonValueProcessor(java.util.Date.class, new JsonDateToStringProcessorImpl());
      config.registerJsonValueProcessor(java.sql.Timestamp.class, new JsonDateToStringProcessorImpl());
      // 忽略父子级别关联
      config.setJsonPropertyFilter(new PropertyFilter() {
        public boolean apply(Object source, String name, Object value) {
          if (name.equals("parentGroup") || name.equals("childGroups")) {
            return true;
          } else {
            return false;
View Full Code Here

    String currentUserName = null;
    try {
      currentUserName = UserUtil.getCurrentUserName(request);
      JsonConfig config = new JsonConfig();
      config.registerJsonValueProcessor(java.sql.Timestamp.class, new JsonDateToStringProcessorImpl());
      config.setJsonPropertyFilter(new PropertyFilter(){
        public boolean apply(Object source, String name, Object value) {
          if(name.equals("parentGroup") || name.equals("childGroups")) {
            return true;
          } else {
            return false;
View Full Code Here

    String currentUserName = null;
    try {
      currentUserName = UserUtil.getCurrentUserName(request);
      JsonConfig config = new JsonConfig();
      config.registerJsonValueProcessor(java.sql.Timestamp.class, new JsonDateToStringProcessorImpl());
      config.setJsonPropertyFilter(new PropertyFilter(){
        public boolean apply(Object source, String name, Object value) {
          if(name.equals("parentGroup") || name.equals("childGroups")) {
            return true;
          } else {
            return false;
View Full Code Here

  /**
   * perform the test
   */
  @Test
  public void testApply() {
    PropertyFilter pf = new NullPropertyFilter();
    Assert.assertTrue(pf.apply(null, null, null));
    JSONArray jsa = new JSONArray();
    Assert.assertTrue(pf.apply(null, null, jsa));
    jsa.add("element");
    Assert.assertFalse(pf.apply(null, null, jsa));
    Assert.assertTrue(pf.apply(null, null, Lists.newArrayList()));
    Assert.assertFalse(pf.apply(null, null, Lists.newArrayList("element", "element")));
    Assert.assertTrue(pf.apply(null, null, new Object[] {}));
    Assert.assertFalse(pf.apply(null, null, new Object[] { "element" }));
  }
View Full Code Here

TOP

Related Classes of net.sf.json.util.PropertyFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.