Reputation: 127
I'm trying to make an app where I will gather information from a json api http://pool-x.eu/api, and print information easly bo choosing parameter.
What is the easiest way to print each of the informations?
Was thinking something in the way of making the information a string, and then request each of the parameters that way, but I don't know if that's the way to do it.
Upvotes: 1
Views: 478
Reputation: 1616
here's a sample code to decode the json data i just happen to make a json text file out if the link you gave and decode it hope it helps
local json = require "json"
local txt
local path = system.pathForFile( "json.txt", system.ResourceDirectory )
local file = io.open( path, "r" )
for line in file:lines() do
txt = line
end
print(txt)
local t = json.decode( txt )
print(t["pool_name"])
print(t["hashrate"])
print(t["workers"])
print(t["share_this_round"])
print(t["last_block"])
print(t["network_hashrate"])
Upvotes: 2