Preventing errors with circular JSON