TehNut-Mods / ResourcefulCrops

Simply JSON based resource crops
MIT License
12 stars 7 forks source link

Allow seed JSON to have "color" :null #52

Closed OrdinatorStouff closed 6 years ago

OrdinatorStouff commented 6 years ago

https://github.com/TehNut/ResourcefulCrops/blob/1.12/src/main/java/tehnut/resourceful/crops/core/json/Serializers.java#L51

I am generating my seed JSONs programmatically and some I might specify a color and some not. It would be helpful to be able to have the color node present but set to null for the seeds that I do not want to specify a color otherwise I will have to manually edit the final seed jsons to take that out.

This is minor and not necessary but a simple suggestion nonetheless.

Thank you.

OrdinatorStouff commented 6 years ago

To add, this is the top part of the error in the log if I do have a json with "color": null

java.lang.UnsupportedOperationException: JsonNull
    at com.google.gson.JsonElement.getAsString(JsonElement.java:191)
    at tehnut.resourceful.crops.core.json.Serializers$1.deserialize(Serializers.java:51)
    at tehnut.resourceful.crops.core.json.Serializers$1.deserialize(Serializers.java:40)