以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  将返回信息填入表格  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=129685)

--  作者:fubblyc
--  发布时间: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编辑过]

--  作者:有点甜
--  发布时间: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
--  发布时间: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

--  作者:有点甜
--  发布时间:2019/1/3 22:37:00
--  

没看懂你的代码的意思。

 

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