Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to deserealise with latest GSON and this library #33

Open
CyborTronik opened this issue Nov 20, 2015 · 1 comment
Open

Not able to deserealise with latest GSON and this library #33

CyborTronik opened this issue Nov 20, 2015 · 1 comment

Comments

@CyborTronik
Copy link

I'm getting:

java.lang.UnsupportedOperationException: JsonObject
    at com.google.gson.JsonElement.getAsString(JsonElement.java:191)
    at com.fatboyindustrial.gsonjodatime.DateTimeConverter.deserialize(DateTimeConverter.java:85)
    at com.fatboyindustrial.gsonjodatime.DateTimeConverter.deserialize(DateTimeConverter.java:44)
    at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
    at com.google.gson.Gson.fromJson(Gson.java:814)
    at com.google.gson.Gson.fromJson(Gson.java:779)
    at com.google.gson.Gson.fromJson(Gson.java:728)
    at com.google.gson.Gson.fromJson(Gson.java:700)

For object with next fields:

private String id;
    private DateTime createdAt;
    private DateTime updatedAt;
    private boolean enabled;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public DateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(DateTime createdAt) {
        this.createdAt = createdAt;
    }

    public DateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(DateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

Using:


        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>com.fatboyindustrial.gson-jodatime-serialisers</groupId>
            <artifactId>gson-jodatime-serialisers</artifactId>
            <version>1.2.0</version>
        </dependency>
@gkopff
Copy link
Owner

gkopff commented Nov 20, 2015

@CyborTronik do you know if this example works okay using GSON 2.3.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants