Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 8 months ago. This question has been closed. Reason: Off Topic
JSON on mbed
hello, through a webservice I receive , after a get request , the json .
{"coord":{"lon":7.28,"lat":43.7},"sys":{"type":3,"id":61624,"message":0.2379,"country":"France","sunrise":1427433653,"sunset":1427478691},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01d"}],"base":"cmc stations","main":{"temp":292.21,"humidity":67.44,"pressure":1005.96,"temp_min":289.84,"temp_max":295.37},"wind":{"speed":2.41,"deg":359.001},"rain":{"3h":0},"clouds":{"all":0},"dt":1427457594,"id":2990440,"name":"Nice","cod":200}
But the trouble is that I would recover for example only the value of Temp ... How could I do? thank you in advance.
2 Answers
9 years, 8 months ago.
I've used picoJSON and it worked great on a resent demo project, which is doing exactly what you are looking for
there is write up here http://www.element14.com/community/roadTestReviews/1984 and more detail here http://www.element14.com/community/people/colin_meikle%40mentor.com/blog/2015/03/23/k64f-mbed-part-2-weather-station and the code here http://developer.mbed.org/users/colinmeikle/code/weather/
From my experience the JSON libraries can be memory intensive, so you may have problems on some boards I'm using K64F I had previously used a K25Z and had problems with memory I suspect and resorted to string matching.
9 years, 8 months ago.
So you need a JSON parser? Try searching for JSON, there are a few already written.
the json is contained in a char variable
posted by MICHAEL danieletto 27 Mar 2015