JSON 파일이 무엇인지 아직 잘 몰라서 배우는데요.
JSON 파일을 만든 후에 콘솔에 보여주고 싶습니다.
잘 안 되는데 왜 안되는지 몰라서요
코드는 아래와 같습니다.
이런 걸 하려면 어떻게 하나요?
<script src="user.json"> let user = enter code here console.log(user) </script>
JSON.parse(obj) 함수를 쓰세요
스크립트 태그를 사용하여 브라우저에서 json 파일을 로드하는 것은 아직 지원되지 않습니다.
가장 쉬운 방법은 Fetch 메서드를 통해 로드하는 것입니다.
fetch('./file.json') .then(response => response.json()) .then(obj => console.log(obj))
16 파이썬에서 The driver cannot recognize the specified command parameter 에러 해결방법
14 python에서 error exception이 발생하도록 하려면?
14 FastApi에서 에러가 뜨는데 ERROR: Error loading ASGI app. Import string "main" must be in format ":". 해결 방법
12 python에서 에러가 생겨도 계속 실행하는 방법
49 PyCaret에서 ImportError: Missing optional dependency 에러가 나는데 해결방법 좀 알려주세요
© 2022 pinfo. All rights reserved.