Setting variable from JSON response URL value

I would like to set a value from the response body as an environmental variable. The
response property is a URL. The response looks like this:

{
    "http://url/sub/sub1": "value1",
    "http://url/sub/sub2": "value2"
}

I have tried adding this to the Tests tab and get unexpected Token error:

var body = JSON.parse(responseBody);
pm.environment.set('passcode', body.http://url/sub/sub1);

pm.environment.set('passcode', body.http://url/sub/sub1); will not work because your property name contains special characters (the invalid token), you need to use braket notation

pm.environment.set('passcode', body['http://url/sub/sub1']);