Package com.google.gson

Examples of com.google.gson.JsonElement


        builder.add(name, prop.getAsLong());
    }

    @Override
    public void integerProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        builder.add(name, prop.getAsBigInteger());
    }
View Full Code Here


        builder.add(name, prop.getAsBigInteger());
    }

    @Override
    public void floatProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        builder.add(name, prop.getAsFloat());
    }
View Full Code Here

        builder.add(name, prop.getAsFloat());
    }

    @Override
    public void doubleProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        builder.add(name, prop.getAsDouble());
    }
View Full Code Here

        builder.add(name, prop.getAsDouble());
    }

    @Override
    public void decimalProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        builder.add(name, prop.getAsBigDecimal());
    }
View Full Code Here

        builder.add(name, prop.getAsBigDecimal());
    }

    @Override
    public void stringProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        builder.add(name, prop.getAsString());
    }
View Full Code Here

    }

    private static final Pattern DATE = Pattern.compile("(\\d{3,})-(\\d{1,2})-(\\d{1,2})");
    @Override
    public void dateProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        String string = prop.getAsString();
        Matcher matcher = DATE.matcher(string);
        if (matcher.matches() == false) {
            throw new IOException(MessageFormat.format(
                    "invalid date property \"{0}\", must be \"{2}\" form, but was \"{1}\"",
                    name,
View Full Code Here

    }

    private static final Pattern TIME = Pattern.compile("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})");
    @Override
    public void timeProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        String string = prop.getAsString();
        Matcher matcher = TIME.matcher(string);
        if (matcher.matches() == false) {
            throw new IOException(MessageFormat.format(
                    "invalid time property \"{0}\", must be \"{2}\" form, but was \"{1}\"",
                    name,
View Full Code Here

    private static final Pattern DATETIME = Pattern.compile(
            "(\\d{3,})-(\\d{1,2})-(\\d{1,2})\\s+(\\d{1,2}):(\\d{1,2}):(\\d{1,2})");
    @Override
    public void datetimeProperty(PropertyName name, JsonObject context) throws IOException {
        JsonElement prop = property(context, name);
        if (prop == null) {
            return;
        }
        String string = prop.getAsString();
        Matcher matcher = DATETIME.matcher(string);
        if (matcher.matches() == false) {
            throw new IOException(MessageFormat.format(
                    "invalid time property \"{0}\", must be \"{2}\" form, but was \"{1}\"",
                    name,
View Full Code Here

        InputStream input = entity.getContent();
        try {
            Reader reader = new BufferedReader(new InputStreamReader(input, ENCODING));
            JsonParser parser = new JsonParser();
            JsonElement element = parser.parse(reader);
            if ((element instanceof JsonObject) == false) {
                throw new IOException(MessageFormat.format(
                        "Response message was not a valid json object: {0} ({1})",
                        request.getURI(),
                        response.getStatusLine()));
View Full Code Here

            response.setEntity(new StringEntity(
                    new Gson().toJson(responseElement).toString(), HttpJobClient.CONTENT_TYPE));
            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                String content = EntityUtils.toString(entity, "UTF-8");
                JsonElement element = parse(content);
                if (element instanceof JsonObject) {
                    requestElement = (JsonObject) element;
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.google.gson.JsonElement

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.