Basically I connected to a server with pharo using identification. Then I used Znclient to get to myserver/json file which contains a collection of key and value. How can I refresh this Json file every 40 sec without running out of memory and How can I iterate over it to collect a specific key?
This is what I did so far
" Login "
"********************************************************"
|a data|
a := ZnClient new.
a get: 'https://MyServer'.
a
headerAt: 'referer' put: 'MyServer';
formAt: 'email' add: 'myEmail';
formAt: 'password' add: 'myPassword'.
a post.
a get: 'MyServer/json'.
" get Json file "
"*******************************************************
data := NeoJSONReader fromString: a contents
You can create a loop that does the work and waits 40 seconds:
Above I assume that
shouldStillRun
andfetchDataAndDoWork
are methods in a class containing these code. If you want to play with this code in the Playground replace them with some custom snippets of code. For example:As long as you do not store all the
data
return by each call you should not have a memory problem.If your data represents a dictionary then
NeoJSON
will return a dictionary object, and you can just use theat:
message to get the value. You can inspect thedata
object to see what you get back.