I want to copy one primitve property from one JsonObject to another
JsonObject propertyToBeCopied = source.getAsJsonObject(propertyName);
but I always run into this exception:
com.google.gson.JsonNull cannot be cast to com.google.gson.JsonObject
According to the documentation it should be possible to do the cast, or am I wrong?
According to the docs
JsonNullis aJsonElementbut not aJsonObject(which is itself aJsonElement). Usingwould return a
JsonElementthat is cast toJsonObjectif it is not of the typeJsonNull.