Foxtable(狐表)用户栏目专家坐堂 → 将返回信息填入表格


  共有2195人关注过本帖树形打印复制链接

主题:将返回信息填入表格

帅哥哟,离线,有人找我吗?
fubblyc
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
将返回信息填入表格  发帖心情 Post By:2019/1/3 21:01:00 [只看该作者]

甜老师,我建了对应字段的表,要将这些填入新增行,自己慢慢调试也可以写出来,但是因为时间紧,可否请甜老师帮忙写一下吗~~~
{
"order_list": [
{
"order_id": "Z2y2rY74ksZX1ceuGA",
"page_id": "abcedfghifk=+Uasdaseq14fadkf8123h4jk",
"trans_id": "4001562001201608292531663351",
"create_time": 123,
"pay_finish_time": 123,
"total_price": 123,
"open_id": "123",
"accepter_openid": "123",
"card_list": [
{
"card_id": "card_id_1",
"price": 123,
"code": "code_123456",
"default_gifting_msg": "",
"background_pic_url": "",
"accepter_openid": "123"
}
],
"outer_str": "web","IsChatRoom": true
},
{
"order_id": "Z2y2rY74ksZX1ceuGA",
"page_id": "abcedfghifk=+Uasdaseq14fadkf8123h4jk",
"trans_id": "4001562001201608292531663351",
"create_time": 123,
"pay_finish_time": 123,
"total_price": 123,
"open_id": "123",
"accepter_openid": "123",
"card_list": [
{
"card_id": "card_id_1",
"price": 123,
"code": "code_123456",
"default_gifting_msg": "",
"background_pic_url": ""
}
],
"outer_str": "web"
}
]
}
[此贴子已经被作者于2019/1/3 21:01:36编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/3 21:34:00 [只看该作者]

1、json要改成

{
"order_list": [
{
"order_id": "Z2y2rY74ksZX1ceuGA",
"page_id": "abcedfghifk=+Uasdaseq14fadkf8123h4jk",
"trans_id": "4001562001201608292531663351",
"create_time": 123,
"pay_finish_time": 123,
"total_price": 123,
"open_id": "123",
"accepter_openid": "123",
"card_list": [
{
"card_id": "card_id_1",
"price": 123,
"code": "code_123456",
"default_gifting_msg": "",
"background_pic_url": "",
"accepter_openid": "123"
}
],
"outer_str": "web",
"IsChatRoom": true
},
{
"order_id": "Z2y2rY74ksZX1ceuGA",
"page_id": "abcedfghifk=+Uasdaseq14fadkf8123h4jk",
"trans_id": "4001562001201608292531663351",
"create_time": 123,
"pay_finish_time": 123,
"total_price": 123,
"open_id": "123",
"accepter_openid": "123",
"card_list": [
{
"card_id": "card_id_1",
"price": 123,
"code": "code_123456",
"default_gifting_msg": "",
"background_pic_url": ""
}
],
"outer_str": "web"
}
]
}
2、代码 
Dim json As String = ClipBoard.GetText
Dim jo As JObject = JObject.Parse(json)
For Each jt As JToken In jo("order_list")
    Output.Show(jt("order_id").ToString & "|" & jt("page_id").ToString)
    For Each jt2 As object In jt("card_list")
        output.show(jt2("card_id").Tostring & "|" & jt2("price").Tostring)
    Next
    output.show("------")
Next

 回到顶部
帅哥哟,离线,有人找我吗?
fubblyc
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
  发帖心情 Post By:2019/1/3 22:05:00 [只看该作者]

甜老师,我这样写,会出现这种错行的情况,要怎么处理呢。。

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20190103220203.png
图片点击可在新窗口打开查看
Dim nms() As String = {"order_id","page_id","trans_id","create_time","pay_finish_time","total_price","open_id","accepter_openid","outer_str","IsChatRoom","background_pic_url","nickname"} '列名
Dim nms1() As String = {"card_id","price","code","default_gifting_msg","background_pic_url","accepter_openid"}
If jo1("errcode") = "0" Then
    Dim ia As JArray = jo1("order_list") '获取的用户信息列表
    For Each jt As JToken In ia
        Dim dr As DataRow = DataTables("微信礼品卡订单信息").Find("order_id = '" & jt("order_id").ToString() & "'")
        If dr Is Nothing Then
            dr = DataTables("微信礼品卡订单信息").AddNew()
            For Each nm As String In nms
                dr(nm) = jt(nm)
            Next
            
            Dim ia1 As JArray = jt("card_list") '获取的用户信息列表
            For Each jt1 As JToken In ia1
                Dim dr1 As DataRow = DataTables("微信礼品卡订单信息").Find("code = '" & jt1("code").ToString() & "' and card_id = '" & jt1("card_id").ToString() & "' ")
                If dr1 Is Nothing Then
                    dr1 = DataTables("微信礼品卡订单信息").AddNew()
                    For Each nm1 As String In nms1
                        dr1(nm1) = jt1(nm1)
                    Next
                End If
            Next
            
        End If
    Next
Else
    output.show("1:" & jo1.ToString)
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/3 22:37:00 [只看该作者]

没看懂你的代码的意思。

 

请上传具体项目,贴出具体json数据,说明最后要做到什么效果。


 回到顶部