Safely parse JSON and return undefined if value is undefined