Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

ColumnNameTypeValueDeserializer have issue when the jsonvalue is null #21

Closed
zlxfamily opened this issue Dec 24, 2014 · 0 comments
Closed
Labels
Milestone

Comments

@zlxfamily
Copy link

public ColumnNameTypeValue deserialize(JsonElement element, Type type, JsonDeserializationContext ctx)
            throws JsonParseException {
        final JsonObject object = element.getAsJsonObject();

        String name = object.get("column").getAsString();
        ColumnType columnType = ColumnType.valueOf(object.get("type").getAsString());
        JsonElement jsonValue = object.get("value");
        Object value = null;
            switch (columnType) {
                case BOOLEAN:
                    value = jsonValue.getAsBoolean();
                    break;
                case DOUBLE:
                    value = jsonValue.getAsDouble();
                    break;
                case FLOAT:
                    value = jsonValue.getAsFloat();
                    break;
                case INTEGER:
                    value = jsonValue.getAsInt();
                    break;
                case LONG:
                    value = jsonValue.getAsLong();
                    break;
                case STRING:
                    value = jsonValue.getAsString();
                    break;
                default:
                    break;
            }


        return new ColumnNameTypeValue(name, columnType, value);
    }

when the jsonValue is null ,it will report a null point error!

@ajnavarro ajnavarro added the bug label Jan 12, 2015
@ajnavarro ajnavarro added this to the 0.6.2 milestone Jan 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants