从 API 请求 JSON 信息.电晕 [英] Requesting JSON information from API. Corona

查看:30
本文介绍了从 API 请求 JSON 信息.电晕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个应用程序,我将从 json api http://pool-x.eu/api,并打印信息很容易bo选择参数.

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.

推荐答案

这是一个解码 json 数据的示例代码,如果您提供并解码它,我只是碰巧制作了一个 json 文本文件,希望对您有帮助

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"])

这篇关于从 API 请求 JSON 信息.电晕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆