Fix crashes caused by miscast of JsonObject to JsonArray or vice versa.