【问题标题】:How to fetch JSON from a website in Flutter如何在 Flutter 中从网站获取 JSON
【发布时间】:2018-05-15 14:38:30
【问题描述】:

我想从我的 Flutter 应用程序中的这个 JSON 中获取 16 作为数字: link to the Json code

【问题讨论】:

标签: dart flutter


【解决方案1】:

您需要导入 async、http 和 convert。

var response = await http.get("http://motyar.info/webscrapemaster/api/?url=http://teertoday.com/&xpath=/html/body/div[5]/div/table/tbody/tr[3]/td[1]#vws");
var jsonResponse = json.decode(response);

var line = jsonResponse["text"].replaceAll(new RegExp(r"(\s\n)"), ""); //this gives you the line of "text" and then replaces all of the spaces and \n

【讨论】:

  • 我很难实现代码你能做一个代码来显示屏幕中心的数字
【解决方案2】:

我不熟悉颤振,但我会读取键“文本”的值,然后用正则表达式过滤它的数字。

【讨论】:

    猜你喜欢
    • 2021-02-14
    • 2019-09-27
    • 1970-01-01
    • 2022-12-21
    • 2019-05-27
    • 2012-07-14
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    相关资源
    最近更新 更多