Let's call John's speed J.
Let's recall that speed is distance/time. Since the current was 1 km per hour, we can consider this as a subtraction when he was swiming against the current, and as an addition when he was swiming with it.
Since speed is distance/time, time is distance/speed.
This gives us, on one hand,

and on the other,

The problem is telling us that these times are the same, so we get the following equation:

To solve it, let's multiply both sides by (J-1)(J+1):


Let's subtract 8 from both sides:

Now, let's subtract 16J from both sides:

Dividing both sides by -8:

So Jhon would swim at a speed of 3 km/h if there were no current.