Can every JSON serializable Java object be represented as a Map<String, Object>?

Viewed 84

I have a bunch of Java objects that are being serialized with Jackson. All of the serialized types look something like this:

class MySampleClass {
    @JsonProperty("propName1")
    private MyCustomType propName1;

    @JsonProperty("propName2")
    private MyOtherCustomType propName2;

    @JsonCreator
    public MySampleClass(@JsonProperty("propName1") MyCustomType propName1, @JsonProperty("propName2") MyOtherCustomType propName2) {
        this.propName1 = propName1;
        this.propName2 = propName2;
    }
}

Is there any case where converting instances of this class to a Map<String, Object> and then converting the map to JSON will not be desearializable back into the original Java object?

1 Answers
Related