Package net.sf.json

Examples of net.sf.json.JsonConfig


        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


      return ERXRestUtils.coerceValueToString(obj, _context);
    }
  }

  public static JsonConfig createDefaultConfig(ERXRestContext context) {
    JsonConfig config = new JsonConfig();
    config.registerJsonValueProcessor(NSTimestamp.class, new GeneralObjectToStringProcessor(context));
    config.registerJsonValueProcessor(LocalDate.class, new GeneralObjectToStringProcessor(context));
    config.registerJsonValueProcessor(LocalDateTime.class, new GeneralObjectToStringProcessor(context));
    config.registerJsonValueProcessor(Date.class, new GeneralObjectToStringProcessor(context));
    config.registerJsonValueProcessor(NSData.class, new GeneralObjectToStringProcessor(context));
    config.registerJsonValueProcessor(ERXCryptoString.class, new GeneralObjectToStringProcessor(context));
    config.setJsonValueProcessorMatcher(new ERXRestValueProcessorMatcher());
    return config;
  }
View Full Code Here

    /**
     * @param _for
     *      Account for which the virtual machine is assigned to.
     */
    public VirtualMachineRef createVirtualMachine(HardwareSpec spec, String _for) throws IOException {
        JsonConfig jsc = new JsonConfig();
        jsc.setIgnoreTransientFields(true);

        String q = _for != null ? "?for=" + _for : "";
        HttpURLConnection con = postJson(open("createVirtualMachine" + q), JSONObject.fromObject(spec,jsc));
        verifyResponseStatus(con);
        return new VirtualMachineRef(new URL(con.getHeaderField("Location")), token);
View Full Code Here

      return;

    ItineraryV2Bean bean = new ItineraryV2Bean();
    JSONObject jsonObject = JSONObject.fromObject(includeSelectedItinerary);

    JsonConfig config = new JsonConfig();

    Map<Object, Object> classMap = new HashMap<Object, Object>();
    classMap.put("legs", LegV2Bean.class);
    classMap.put("streetLegs", StreetLegV2Bean.class);
    classMap.put("situationIds", String.class);
    config.setClassMap(classMap);

    JSONObject.toBean(jsonObject, bean, config);

    ItineraryBean itinerary = itineraryFactory.reverseItinerary(bean);
    constraints.setSelectedItinerary(itinerary);
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

    return WebUtils.toString(bandInfo);
  }
 
  public JsonUtils()
  {
    jsonConfig = new JsonConfig();

    jsonConfig.registerJsonValueProcessor(DateTime.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
View Full Code Here

    return WebUtils.toString(bandInfo);
  }

  public JsonUtils()
  {
    jsonConfig = new JsonConfig();

    jsonConfig.registerJsonValueProcessor(DateTime.class, new JsonValueProcessor()
    {
      public Object processArrayValue(Object arg0, JsonConfig arg1)
      {
View Full Code Here

   
    scriptVO.setAllowedTemplates(allowedTemplateIdsList);
    scriptVO.setActionIds(actionIdsList);
    scriptVO.setStatIds(statIdsList);
   
    JsonConfig config = new JsonConfig()
        config.registerJsonValueProcessor(Timestamp.class, new DateJsonValueProcessor());
        JSONObject json = JSONObject.fromObject(scriptVO,config);
        return json.toString();
  }
View Full Code Here

   */
  @RequestMapping("/getAllScript.do")
  @ResponseBody
  public String getAllScript() throws Exception {
    List<Script> scripts = das.queryAllScripts();
    JsonConfig config = new JsonConfig()
        config.registerJsonValueProcessor(Timestamp.class, new DateJsonValueProcessor());
    JSONArray json = JSONArray.fromObject(scripts,config);
    return json.toString();
  }
View Full Code Here

    response.setContentType("application/json");
    response.getWriter().print(jsonObject.toString());
  }
 
  public static void respons2JsonArrayHibernate(HttpServletResponse response, Object json) throws IOException {
    JsonConfig jsonConfig = new JsonConfig()
    jsonConfig.setExcludes(new String[]{"delegate"})
    jsonConfig.setExcludes(new String[]{"transactionTimeout"});
    jsonConfig.registerJsonBeanProcessor(org.hibernate.proxy.HibernateProxy.class, new HibernateJsonBeanProcessor());
    jsonConfig.setJsonBeanProcessorMatcher(new HibernateJsonBeanProcessorMatcher());
    JSON jsonObject = JSONSerializer.toJSON(json,jsonConfig);
    response.setContentType("application/json");
    response.getWriter().print(jsonObject.toString());
  }
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.