以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  WebApi接口  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=160225)

--  作者:237756360
--  发布时间:2021/1/25 15:59:00
--  WebApi接口
WebApi接口调试成功了,请问怎么转换成狐表支持的呢?辛苦蓝板了。

调试代码:
POST:
http://172.16.24.47:800/api/App/Single/BC2FBCA5C701B2E0530AD

请求:
{
  "AppCode": "54C9ADE1FF943B1345DAAB03",
  "Where": {
  "JINGHAO":"95-99"
  },
  "Sort": "",
  "Order": ""
}



接收到的:

{
    "code": 200,
    "info": "响应成功",
    "data": {
        "JINGHAO": "95-99",
        "DANWEI": "123123",
        "RIQI": "2011-10-02T00:00:00",
        "SCSHIJIAN": 0,
        "RICYE": 0,
        "RICYOU": 0,
        "RICSHUI": 0,
        "YOUYA": null,
        "TAOYA": null,
        "GJYOUYA": null,
        "GJTAOYA": null,
        "HYHANSHUI": null,
        "KOUSHUI": null,
        "KSSHIJAN": null,
        "JSSHIJIAN": null,
        "YALI": null,
        "PAILIANG": null,
        "JKWENDU": null,
        "CKWENDU": null
    }
}
[此贴子已经被作者于2021/1/25 18:49:18编辑过]

--  作者:有点蓝
--  发布时间:2021/1/25 16:03:00
--  
Dim hc As New HttpClient("http://10.217.124.147:5000/api/App/Single/B89C2FBCA5C701B2E0530AD97B4CA4DD")
hc
.ContentType = "application/json"
Dim jo As New JObject
jo
("AppCode") = "145C9ADE1FF943B1345D647AAB031555"
……自行添加其它json数据
hc.Content = jo.ToString
Dim
 ret As String = hc.GetData()
MessageBox
.Show(ret)

--  作者:237756360
--  发布时间:2021/1/25 18:27:00
--  
多谢
--  作者:小美菜
--  发布时间:2021/1/25 20:40:00
--  
这个要学习一下
--  作者:237756360
--  发布时间:2021/2/1 9:24:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:a44fa97b7fdf8d8b3763b2683232582.png
图片点击可在新窗口打开查看


下面这是输出的数据要保存到表格内。上面的是报错信息

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20210201092612.png
图片点击可在新窗口打开查看


蓝板,我把上面的数据输出到表格内,报错,请问哪里出错了了呢!

For Each jt As JToken In ret
    With Tables("表A")
        Dim r As Row =.addnew()
        r("第一列")=jt("JINGHAO").tostring
        r("第二列")=jt("RIQI").tostring
    End With
Next
[此贴子已经被作者于2021/2/1 9:28:58编辑过]

--  作者:有点蓝
--  发布时间:2021/2/1 9:39:00
--  
json里不存在"JINGHAO"这个数据

帖出完整的解析代码

--  作者:237756360
--  发布时间:2021/2/1 9:58:00
--  
代码:
Dim hc As New HttpClient("http://192.27.162.177:5000/api/App/Single/B24D43543534397B4CA")
hc.C
Dim jo As New JObject
jo("AppCode") = "234234234E1FF943B1345D647A6756765756"
jo("Where")=New JObject
jo("Where")("RIQI")="2021-01-25"
jo("Where")("JINGHAO")="11-11-11"
hc.Content = jo.ToString
Dim ret As String = hc.GetData()
\'MessageBox.Show(ret.Tostring)
For Each jt As JToken In ret
    With Tables("表A")
        Dim r As Row =.addnew()
        r("第一列")=jt("JINGHAO").tostring
        r("第二列")=jt("RIQI").tostring
    End With
Next




解析出来的数据
{"code":200,"info":"响应成功","data":{"JINGHAO":"11-11-11","DANWEI":"采购部门","RIQI":"2021-01-25","SCSHIJIAN":0,"RICYE":0,"RICYOU":0,"RICSHUI":0,"YOUYA":0.5,"TAOYA":0.6,"GJYOUYA":null,"GJTAOYA":null,"HYHANSHUI":null,"KOUSHUI":null,"KSSHIJAN":null,"JSSHIJIAN":null,"YALI":null,"PAILIANG":null,"JKWENDU":null,"CKWENDU":null}}
[此贴子已经被作者于2021/2/1 10:02:15编辑过]

--  作者:有点蓝
--  发布时间:2021/2/1 10:03:00
--  
http://www.foxtable.com/mobilehelp/topics/0140.htm

Dim ret As String = hc.GetData()
Dim jo As JObject = JObject.Parse(ret)
msgbox(jo("data")("RIQI").tostring)
msgbox(jo("data")("TAOYA").tostring)

--  作者:237756360
--  发布时间:2021/2/1 10:18:00
--  
解析出来的数据
{"code":200,"info":"响应成功","data":{"JINGHAO":"11-11-11","DANWEI":"采购部门","RIQI":"2021-01-25","SCSHIJIAN":0,"RICYE":0,"RICYOU":0,"RICSHUI":0,"YOUYA":0.5,"TAOYA":0.6,"GJYOUYA":null,"GJTAOYA":null,"HYHANSHUI":null,"KOUSHUI":null,"KSSHIJAN":null,"JSSHIJIAN":null,"YALI":null,"PAILIANG":null,"JKWENDU":null,"CKWENDU":null}}


我想把解析出来的数据放在表格里,才出现的报错,蓝板辛苦了。
代码:
Dim hc As New HttpClient("http://192.27.162.177:5000/api/App/Single/B24D43543534397B4CA")
hc.C
Dim jo As New JObject
jo("AppCode") = "234234234E1FF943B1345D647A6756765756"
jo("Where")=New JObject
jo("Where")("RIQI")="2021-01-25"
jo("Where")("JINGHAO")="11-11-11"
hc.Content = jo.ToString
Dim ret As String = hc.GetData()
\'MessageBox.Show(ret.Tostring)
For Each jt As JToken In ret
    With Tables("表A")
        Dim r As Row =.addnew()
        r("第一列")=jt("JINGHAO").tostring
        r("第二列")=jt("RIQI").tostring
    End With
Next

--  作者:有点蓝
--  发布时间:2021/2/1 10:24:00
--  
看8楼