Cast json only if it exists