Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이종상
/
OSS-2021-Project2015
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
ToLive
2021-06-10 15:50:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
acaa42937b59a5429ede98ad8f4f41370f4ac4c2
acaa4293
1 parent
8000804c
JSON name 알고리즘 수정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
Project/app.js
Project/app.js
View file @
acaa429
...
...
@@ -16,9 +16,11 @@ const bodyParser = require('body-parser');
var
app
=
express
();
var
stack
=
0
;
var
meal
,
country
,
cold
,
spicy
,
name
;
//name 추가
const
FoodArray
;
//meal, country, cold, spicy를 이용해 해당 객체를 가져오는 배열변수
const
FoodData
=
fs
.
readFileSync
(
"./FoodList.json"
,
{
encoding
:
"utf-8"
});
//FoodData 객체
const
FoodData
=
fs
.
readFileSync
(
"./FoodList.json"
,
{
encoding
:
"utf-8"
});
//FoodData 객체 (OK)
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
...
...
@@ -189,12 +191,20 @@ https://developers.naver.com/docs/search/local/
로컬 변수 값을 바탕으로 name을 JSON파일에서 찾기
*/
// arr은 해당 JSON값을 가진 객체를 출력함
FoodData
.
filter
(
function
(
e
){
FoodArray
=
e
.
meal
===
meal
&&
e
.
country
===
country
&&
e
.
spicy
===
spicy
&&
e
.
cold
===
cold
;
})
name
=
FoodArray
[
name
];
//name에 해당 속성에 맞는 음식 이름을 삽입
var
parseObject
=
Object
.
values
(
FoodObject
).
filter
(
function
(
e
){
return
e
.
meal
===
meal
&&
e
.
country
===
country
&&
e
.
spicy
===
spicy
&&
e
.
cold
===
cold
;
});
name
=
parseObject
[
0
].
name
;
request
.
post
(
{
...
...
Please
register
or
login
to post a comment