Package net.sf.json

Examples of net.sf.json.JSON


    action.setQ("");
    String okay = action.execute();
    assertEquals(ActionSupport.SUCCESS,okay);
    List<String> tags = action.getSkosRelatedTags();
    assertTrue(tags.isEmpty());
    JSON json = action.getJsonResult();
    assertEquals("{}",json.toString());
  }
View Full Code Here


    if(jsonName == null){
      final String message = "Required parameter 'jsonName' is not found.";
      throw new RuntimeException(message);
    }
    ServletActionContext.getResponse().setContentType("text/javascript; charset=UTF-8");
    JSON json = (JSON)actionInvocation.getStack().findValue(jsonName);
    if(json != null){
      Writer out = null;
      try{
        out = ServletActionContext.getResponse().getWriter();
        out.append(json.toString());
      }catch(Exception e){
        logger.error("Error write json object: " + e.getMessage(), e);
      }finally{
        if(out != null){
          out.close();
View Full Code Here

     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        JSON json = null;
       
        if( JSONUtils.isObject( obj ))
        {
            json = JSONObject.fromObject( obj );           
        }
View Full Code Here

        }
        return JSONObject.fromObject(obj, config);
    }

    public String toXML(Object obj) {
        JSON json = _toJson(obj);
        XMLSerializer xmlSerializer = new XMLSerializer();
        return xmlSerializer.write(json);
    }
View Full Code Here

    public JSONArray paramAsJSONArray(String key) {
        return JSONArray.fromObject(param(key));
    }

    public JSONObject paramAsJSON() {
        JSON json = _contentAsJSON();
        if (json.isArray()) {
            throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        }
        return (JSONObject) json;
    }
View Full Code Here

        }
        return (JSONObject) json;
    }

    public JSONArray paramsAsJSONArray() {
        JSON json = _contentAsJSON();
        if (!json.isArray()) throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        return (JSONArray) json;
    }
View Full Code Here

        }

    }

    public JSONArray paramAsXMLArray() {
        JSON json = _contentAsXML();
        if (!json.isArray()) throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        return (JSONArray) json;
    }
View Full Code Here

        if (!json.isArray()) throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        return (JSONArray) json;
    }

    public JSONObject paramAsXML() {
        JSON json = _contentAsXML();
        if (json.isArray()) {
            throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        }
        return (JSONObject) json;
    }
View Full Code Here

    }

    private JSON _contentAsXML() {
        try {
            XMLSerializer xmlSerializer = new XMLSerializer();
            JSON json = xmlSerializer.read(contentAsString());
            return json;
        } catch (Exception e) {
            throw new ArgumentErrorException("数据格式错误,您需要传入json格式");
        }
    }
View Full Code Here

            }
            result.put("result", variables);
        }

        ServletOutputStream outputStream = response.getOutputStream();
        JSON json = JSONSerializer.toJSON(result);
        outputStream.print(json.toString());
        outputStream.flush();
    }
View Full Code Here

TOP

Related Classes of net.sf.json.JSON

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.