Attempting to handle JSON self-referencing loop - not succeeding