Made setting env variables from JSON more robust.