I keep getting “Uncaught SyntaxError: Unexpected token o”

前端 未结 9 1542
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 01:46

I\'m trying to learn some html/css/javascript, so I\'m writing myself a teaching project.

The idea was to have some vocabulary contained in a json file which would t

9条回答
  •  别那么骄傲
    2020-11-22 02:18

    const getCircularReplacer = () => {
                  const seen = new WeakSet();
                  return (key, value) => {
                    if (typeof value === "object" && value !== null) {
                      if (seen.has(value)) {
                        return;
                      }
                      seen.add(value);
                    }
                    return value;
                  };
                };
    JSON.stringify(tempActivity, getCircularReplacer());
    

    Where tempActivity is fething the data which produces the error "SyntaxError: Unexpected token o in JSON at position 1 - Stack Overflow"

提交回复
热议问题