Package net.sf.json

Examples of net.sf.json.JsonConfig


     * @param contentType
     * @throws IOException
     * @throws NotAuthorizedException
     */
    public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException {
        JsonConfig cfg = new JsonConfig();
        cfg.setIgnoreTransientFields(true);
        cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);

        NewFile[] arr;
        if (newFiles != null) {
            arr = new NewFile[newFiles.size()];
        } else {
View Full Code Here


    return JSONSerializer.toJava(json, jsonConfig);
  }

  // 灏咼ava瀵硅薄杞崲鎴怞SON瀵硅薄
  public static JSONObject toJSONObject(Object object) {
    JsonConfig jsonConfig = new JsonConfig();
    return (JSONObject) JSONSerializer.toJSON(object, jsonConfig);
  }
View Full Code Here

  public static void main(String[] args) {
    JsDateJsonBeanProcessor beanProcessor = new JsDateJsonBeanProcessor();
        java.sql.Date d = new java.sql.Date(System.currentTimeMillis());

        // 直接序列化
        JsonConfig config = new JsonConfig();
        JSONObject json = beanProcessor.processBean(d, config);
        System.out.println(json.toString());
       
        Vector v = new Vector();
        v.add("1");
View Full Code Here

    Long financeMoneyDetailId = StringUtil.getLongValue(request, "id");
    try {
      currentUserName = UserUtil.getCurrentUserName(request);
      FinanceMoneyDetail financeMoneyDetail = (FinanceMoneyDetail) getBaseManager().get(FinanceMoneyDetail.class,
          financeMoneyDetailId);
      JsonConfig config = new JsonConfig();
      // 注册日期解析器
      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

      HttpServletResponse response) throws Exception {
    Long iouserId = StringUtil.getLongValue(request, "id");
    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

      HttpServletResponse response) throws Exception {
    Long groupId = StringUtil.getLongValue(request, "id");
    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

    @Test
    public void testJSON() throws Exception {
        List<String> lines = IOUtils.readLines(this.getClass().getClassLoader().getResourceAsStream("VAB8339-00095.json"));
        JSONObject jo = (JSONObject) JSONSerializer.toJSON(StringUtils.join(lines, "\n"));
        assertNotNull(jo);
        JsonConfig config = new JsonConfig();
        config.setExcludes(new String[] {"item"});
        JSONObject jo2 = JSONObject.fromObject(jo, config);
        assertNotNull(jo2);
    }
View Full Code Here

    String jsonString;

    if (data == null) {
      jsonString = "{}";
    } else {
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.setExcludes(excludes);
      jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
      jsonConfig.setJsonPropertyFilter(ignoreNullFilter);
      Object jsObj = JSONSerializer.toJSON(data, jsonConfig);
      jsonString = jsObj.toString();
    }

    try {
View Full Code Here

            sb.append(buffer, 0, len);
        }
        if (target != null && sb.length() > 0 && sb.charAt(0) == '[') {
            JSONArray jsonArray = JSONArray.fromObject(sb.toString());
            if (target.getClass().isArray()) {
                JSONArray.toArray(jsonArray, target, new JsonConfig());
            } else {
                JSONArray.toList(jsonArray, target, new JsonConfig());
            }

        } else {
            JSONObject jsonObject = JSONObject.fromObject(sb.toString());
            JSONObject.toBean(jsonObject, target, new JsonConfig());
        }
    }
View Full Code Here

  private AchievementBean[] parseAchievementsJSon(String json)
  {
    JSONUtils.getMorpherRegistry().registerMorpher( new EnumMorpher( Category.class ) );
    JSONUtils.getMorpherRegistry().registerMorpher( new EnumMorpher( Difficulty.class ) );
    JSONArray jsonArray = (JSONArray) JSONSerializer.toJSON(json);
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.setArrayMode( JsonConfig.MODE_OBJECT_ARRAY );
    jsonConfig.setRootClass(AchievementBean.class);

    return (AchievementBean[]) JSONSerializer.toJava( jsonArray, jsonConfig );
  }
View Full Code Here

TOP

Related Classes of net.sf.json.JsonConfig

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.