Package net.sf.json

Examples of net.sf.json.JSONObject.toBean()


    protected <T extends BaseJsonObject> T getResource(String path, Class<T> type) throws IOException {
        HttpURLConnection con = open(path);
        try {
            JSONObject json = JSONObject.fromObject(IOUtils.toString(con.getInputStream(), "UTF-8"));
            T resource = (T) json.toBean(type);
            resource.json = json;
            return resource;
        } catch (IOException e) {
            throw wrappedException(con, e);
        }
View Full Code Here


    /**
     * Gets a property with databinding.
     */
    public <T extends Property> T getProperty(String name, Class<T> type) {
        JSONObject o = getProperty(name);
        return o!=null ? type.cast(o.toBean(type)) : null;
    }

    /**
     * Gets a property with databinding. The type must have {@link com.cloudbees.mtslaves.client.properties.PropertyName} annotation on it.
     */
 
View Full Code Here

    protected <T extends BaseJsonObject> T getResource(String path, Class<T> type) throws IOException {
        HttpURLConnection con = open(path);
        try {
            JSONObject json = JSONObject.fromObject(IOUtils.toString(con.getInputStream(), "UTF-8"));
            T resource = (T) json.toBean(type);
            resource.json = json;
            return resource;
        } catch (IOException e) {
            InputStream es = con.getErrorStream();
            String payload = es!=null ? IOUtils.toString(es) : "(no data)";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.