AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Jo-t1001 question
 
 

hi! Im a beginner in cs
I want to link the weather api.
Im trying to connect Seoul weather from https://openweathermap.org/city/1835848
The result value of api is

{"coord":{"lon":126.98,"lat":37.57},
“weather”:[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],
“base”:“stations”,
“main”:{"temp":301.13,"pressure":1010,"humidity":37,"temp_min":298.15,"temp_max":303.15},
“visibility”:11265,“wind”:{"speed":3.6,"deg":190},
“clouds”:{"all":75},
“dt”:1528181880,
“sys”:{"type":1,"id":7673,"message":0.0098,"country":"KR","sunrise":1528143076,"sunset":1528195808},
“id”:1835848,“name”:“Seoul”,“cod”:200}

I just want to use what i want to use here.

This is my weather.top file
========================================================
concept: ~날씨 NOUN [ 오늘 날씨 한국날씨 오늘날씨 ]
concept: ~지역 NOUN [ 서울시 성남시 수원시 용인시 울산광역시 인천광역시 seoul gangdong-gu ]

Topic: ~WEATHER keep repeat ( ~날씨 ~지역 )

u: ( ~날씨 ) 지역을 먼저 말해주세요.
u: ( _~지역 ) $location = ‘_0 ^keep() repeat()
$_var = ^jsoncreate(transient object)
$_var.fieldname = $myvar
$_var = ^jsonparse(^”{ fieldname: $myvar }”)
$_url = ^“http://api.openweathermap.org/data/2.5/weatherq=$location,KR&APPID=5b5548dbbdde086446b1d0f2601c2571”
$_userAgent = ^“User-Agent: %bot, ChatScript”
^jsonopen( post $_url “” $_userAgent )

==========================================================

but result is Jo-t1001
Is the result of api long? ㅠ_ㅠ?
Thanks for the answer!

 

 
  [ # 1 ]

That is the name reference for a json object. You can retrieve data from it, eg by dot selection.

$_obj = ^jsonopen…

$_object.coord is a piece or $_object.coord.lon drills down depper.

 

 
  [ # 2 ]

Thanks! The answer was very helpul:-)

 

 
  login or register to react