Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- server
- kakao
- 구글
- caddy
- php
- centOS7
- 번역
- unity
- 안드로이드
- 개발자
- 해석
- mariadb
- javascript
- Portfolio
- techEmpower
- 프래그먼트
- C
- 컴퓨터과학총론
- 자바
- java
- 한글
- android
- error
- ubuntu
- 개발
- H2O
- NGINX
- MySQL
- C lanuage
- it
Archives
- Today
- Total
개발모음집
JSON 구조를 객체쓰지 않고 만들때 실수한 점 본문
geos = `{"ip": "${parseData.httpData.ip}", "country": "${geo.country}", "city": "${geo.city}", "latLng": "${geo.ll}"}`;
return res.status(200).json(`[ ${geos} ]`);
// 틀린 코드
geos = `{"ip": ${parseData.httpData.ip}, "country": ${geo.country}, "city": ${geo.city}, "latLng": ${geo.ll}}`;
return res.status(200).json(`"geos" : [ ${geos} ]`);
// 맞는 코드
geos = `{"ip": "${parseData.httpData.ip}", "country": "${geo.country}", "city": "${geo.city}", "latLng": "${geo.ll}"}`;
return res.status(200).json(`[ ${geos} ]`);
여기서 실수한 점
1. return 할 때 JSON 배열에 이름을 붙여줌.
res.status(200).json(`"geos" : [ ${geos} ]`);
http://tcpschool.com/json/json_basic_structure
코딩교육 티씨피스쿨
4차산업혁명, 코딩교육, 소프트웨어교육, 코딩기초, SW코딩, 기초코딩부터 자바 파이썬 등
tcpschool.com
2. JSON 값에 ""로 감싸지 않음
'client' 카테고리의 다른 글
Node.JS : WebStorm “require”사용시 Unresolved function or method Error (0) | 2019.11.27 |
---|---|
TypeError: this.cliEngine is not a constructor (0) | 2019.10.30 |
webstorm terminal console font size (0) | 2019.07.29 |
javasrcript crawler, puppeteer RR_TUNNEL_CONNECTION_FAILED (0) | 2019.06.14 |
sequelize deprecated String based operators are now deprecated. (0) | 2019.03.16 |