Foxtable(狐表)用户栏目专家坐堂 → 解析


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

主题:解析

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
解析  发帖心情 Post By:2016/12/28 15:11:00 [显示全部帖子]

假如对方给我返回的是多个{},每个{}里面的格式都是相同的。
下面的是针对单个{}计划表增加一行,多个{},计划表需要增加多行,怎么做呢? 
If dr2 Is Nothing Then
                Dim dl As new ClassLibrary1.Class1()
                Dim Multi As String =dl.getSchInfoByWorkInfo(str1,str2)
                If Multi.Length = 0 Then
                    MessageBox.show("工单号行号:" & str & "没有导入订单系统,请告知计划人员","异常",MessageBoxButtons.OK,MessageBoxIcon.Error)
                Else
                    multi = multi.Replace("{","").Replace("}","")
                    Dim Values() As String
                    Values = Multi.split(",")
                    Dim zd As New Dictionary(Of String, String)
                    zd.Add("u8OrderNo","订单号")
                    zd.Add("u8LineNo","订单行号")
                    zd.Add("productNo","客户物料编码")
                    zd.Add("productType","客户物料名称")
                    zd.Add("bdMaterialNo","博达物料编码")
                    zd.Add("bdMaterialName","博达物料名称")
                    zd.Add("productionQuantity","生产订单数量")
                    zd.Add("typeDscr","类别说明")
                    zd.Add("depName","部门名称")
                    zd.Add("startDate","开工日期")
                    zd.Add("endDate","完工日期")
                    zd.Add("activeOSNo","两化表编号")
                    zd.Add("remark","备注")
                    zd.Add("swVersion","软件版本")
                    Dim rr As Row = Tables("计划表").AddNew
                    For Index As Integer = 0 To Values.Length - 1
                        Dim vrr() As String = Values(Index).split(":")
                        rr(zd(vrr(0))) = vrr(1)
                    Next
                    rr("生产订单号码") = str1
                    rr("工单行号") = str2
                    rr("工单") = str1 & "-" & str2
                    rr.save
                    rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
                    rr.save
                End If
            End If


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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/28 16:52:00 [显示全部帖子]

[{"u8OrderNo":"SY1510105-1","u8LineNo":"1","productNo":"CBSWI-SWI1563A","productType":"BDCOM S2520PT","bdMaterialNo":"TEROU-ROU0360B","bdMaterialName":"CBOEM-PON0150B","productionQuantity":"2","typeDscr":"正常生产","depName":"制造中心-装配部-批量","startDate":"2015/12/9 0:00:00","endDate":"2015/12/12 0:00:00","activeOSNo":"Oeout7S03e00101","remark":"通用态","swVersion":"09039_2015"},
{"u8OrderNo":"SY1510105-2","u8LineNo":"2","productNo":"CBSWI-SWI1563B","productType":"BDCOM S2520MT","bdMaterialNo":"TEROU-ROU0360A","bdMaterialName":"CBOEM-PON0150A","productionQuantity":"4","typeDscr":"正常生产","depName":"制造中心-装配部-批量","startDate":"2015/12/8 0:00:00","endDate":"2015/12/11 0:00:00","activeOSNo":"Oeout7S03e00102","remark":"通用态","swVersion":"09049_2015"}]
是json格式。
在json.cn能在线解析

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

还是不清楚怎么把他们加入到我的计划表里面。如果只有1行数据的,红色代码是通过字典的方式加入的。
请指教。

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/28 17:33:00 [显示全部帖子]

不管一行还是多行,都返回给我的是这种格式。一行一个{},我如何把每行的值写到计划表里面
[{"a":"1","a1":"12"},{"b":"2","b1":"22"},{"c":"3","c1":"333"}]

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


[此贴子已经被作者于2016/12/28 17:38:11编辑过]

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/29 16:19:00 [显示全部帖子]

Dim dr2 As DataRow = DataTables("计划表").SQLFind("工单= '" & gdhhh.text & "'")
            If dr2 Is Nothing Then
                Dim dl As new ClassLibrary1.Class1()
                Dim Multi As String =dl.getSchInfoByWorkInfo(str1,str2)
                If Multi.Length = 0 Then
                    MessageBox.show("工单号行号:" & str & "没有导入订单系统,请告知计划人员","异常",MessageBoxButtons.OK,MessageBoxIcon.Error)
                Else              
                    Dim data As object
                    Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
                    Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
                    With ScriptControl
                        .Language = "Javascript"
                        .Timeout = -1
                        .AddCode(JscriptCode)
                        data = .Run("toObject", Multi)
                    End With
                    For Each info As object In data
                        Dim rr As Row = Tables("计划表").AddNew
                        rr("订单号") = Info.u8OrderNo
                        rr("订单行号") = Info.u8LineNo
                        rr("客户物料编码") = Info.productNo
                        rr("客户物料名称") = Info.productType
                        rr("博达物料编码") = Info.bdMaterialNo
                        rr("博达物料名称") = Info.bdMaterialName
                        rr("生产订单数量") = Info.productionQuantity
                        rr("类别说明") = Info.typeDscr
                        rr("部门名称") = Info.depName
                        rr("开工日期") = Info.startDate
                        rr("完工日期") = Info.endDate
                        rr("两化表编号") = Info.activeOSNo
                        rr("备注") = Info.remark
                        rr("软件版本") = Info.swVersion
                        rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
                        rr.save                        
                    Next                    
                End If
            End If


老师能发针对红色的代码写一下备注,不理解啥意思。另外for each里面的也应该对的把。

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/30 14:02:00 [显示全部帖子]

我在命令窗口运行下面的代码结果就是正确的。
Dim str As String = "[{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""1"",""u8OrderNo"":""021607102"",""u8LineNo"":""13"",""productNo"":""CBSWI-SWI1630A"",""productType"":""LS6803"",""bdMaterialNo"":""CBSWI-SWI1630A"",""bdMaterialName"":""LS6803"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":"""",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""2"",""u8OrderNo"":""021607102"",""u8LineNo"":""9"",""productNo"":""CBSWI-JCA0772B"",""productType"":""LS68-24GE-SFP-V3"",""bdMaterialNo"":""CBSWI-JCA0772B"",""bdMaterialName"":""LS68-24GE-SFP-V3"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""3"",""u8OrderNo"":""021607102"",""u8LineNo"":""10"",""productNo"":""CBSWI-JCA0790B"",""productType"":""LS68-MSU-III-B"",""bdMaterialNo"":""CBSWI-JCA0790B"",""bdMaterialName"":""LS68-MSU-III-B"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""4"",""u8OrderNo"":""021607102"",""u8LineNo"":""11"",""productNo"":""CBPOW-POW0112A"",""productType"":""英文中性化LS68-PWR-AC-600"",""bdMaterialNo"":""CBPOW-POW0112A"",""bdMaterialName"":""英文中性化LS68-PWR-AC-600"",""productionQuantity"":""2"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*2"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""5"",""u8OrderNo"":""021607102"",""u8LineNo"":""12"",""productNo"":""CBSWI-JCA0774B"",""productType"":""LS68-12GE-TX/SFP-V3"",""bdMaterialNo"":""CBSWI-JCA0774B"",""bdMaterialName"":""LS68-12GE-TX/SFP-V3"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""}]"
msgbox(str)
Dim data As object
Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", str)
    
End With
For Each info As object In data
    Dim rr As Row = Tables("计划表").AddNew
    rr("生产订单号码") = Info.workOrderNo
    rr("工单行号") = Info.workOrderLineNo
    rr("工单") = rr("生产订单号码") & "-" & rr("工单行号")
    rr("订单号") = Info.u8OrderNo
    rr("订单行号") = Info.u8LineNo
    rr("客户物料编码") = Info.productNo
    rr("客户物料名称") = Info.productType
    rr("博达物料编码") = Info.bdMaterialNo
    rr("博达物料名称") = Info.bdMaterialName
    rr("生产订单数量") = Info.productionQuantity
    rr("类别说明") = Info.typeDscr
    rr("部门名称") = Info.depName
    rr("开工日期") = Info.startDate
    rr("完工日期") = Info.endDate
    rr("两化表编号") = Info.activeOSNo
    rr("备注") = Info.remark
    rr("软件版本") = Info.swVersion
    rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
    rr.save
Next
如果在keydown运行,
就提示错误所在事件:窗口,生产入库,TextBox3,KeyDown
详细错误信息:
缺少 ';
 Dim dl As new ClassLibrary1.Class1()
            Dim Multi As String =dl.getSchInfoByWorkInfo_1(str1,str2)
            If Multi.Length = 0 Then
                MessageBox.show("工单号行号:" & str & "没有导入订单系统,请告知计划人员","异常",MessageBoxButtons.OK,MessageBoxIcon.Error)
            Else                
                msgbox (Multi)
                Dim data As object
                Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
                Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
                With ScriptControl
                    .Language = "Javascript"
                    .Timeout = -1
                    .AddCode(JscriptCode)
                    data = .Run("toObject", Multi)                    
                End With
                For Each info As object In data
                    Dim rr As Row = Tables("计划表").AddNew
                    rr("生产订单号码") = Info.workOrderNo
                    rr("工单行号") = Info.workOrderLineNo
                    rr("工单") = rr("生产订单号码") & "-" & rr("工单行号")
                    rr("订单号") = Info.u8OrderNo
                    rr("订单行号") = Info.u8LineNo
                    rr("客户物料编码") = Info.productNo
                    rr("客户物料名称") = Info.productType
                    rr("博达物料编码") = Info.bdMaterialNo
                    rr("博达物料名称") = Info.bdMaterialName
                    rr("生产订单数量") = Info.productionQuantity
                    rr("类别说明") = Info.typeDscr
                    rr("部门名称") = Info.depName
                    rr("开工日期") = Info.startDate
                    rr("完工日期") = Info.endDate
                    rr("两化表编号") = Info.activeOSNo
                    rr("备注") = Info.remark
                    rr("软件版本") = Info.swVersion
                    rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
                    rr.save
                Next
            End If
发现2个msgbox(str)和msgbox(Multi),结果不一样。一个去掉了多余的引号,一个仍然是返回的原值引号仍然保留
msgbox(str)

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

图片点击可在新窗口打开查看此主题相关图片如下:mutl.png
图片点击可在新窗口打开查看
这是怎么回事呢?怎么改呢?ths
[此贴子已经被作者于2016/12/30 14:03:23编辑过]

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/30 15:02:00 [显示全部帖子]

接口返回的就是那样的格式。
我该怎么改?

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/30 15:10:00 [显示全部帖子]

还真是我要求人家返回这种格式的。
我当时是按照你的代码。看到有双引号的。
那现在是不是让他返回下面的就对了?
[{"workOrderNo":"SC20160810103","workOrderLineNo":"1","u8OrderNo":"021607102","u8LineNo":"13","productNo":"CBSWI-SWI1630A","productType":"LS6803","bdMaterialNo":"CBSWI-SWI1630A","bdMaterialName":"LS6803","productionQuantity":"1","typeDscr":"","depName":"制造中心-装配部-高端","startDate":"2016-08-17 00:00:00.0","endDate":"2016-08-22 00:00:00.0","activeOSNo":"","remark":"","swVersion":""},{"workOrderNo":"SC20160810103","workOrderLineNo":"2","u8OrderNo":"021607102","u8LineNo":"9","productNo":"CBSWI-JCA0772B","productType":"LS68-24GE-SFP-V3","bdMaterialNo":"CBSWI-JCA0772B","bdMaterialName":"LS68-24GE-SFP-V3","productionQuantity":"1","typeDscr":"","depName":"制造中心-装配部-高端","startDate":"2016-08-17 00:00:00.0","endDate":"2016-08-22 00:00:00.0","activeOSNo":"","remark":"1*1","swVersion":""},{"workOrderNo":"SC20160810103","workOrderLineNo":"3","u8OrderNo":"021607102","u8LineNo":"10","productNo":"CBSWI-JCA0790B","productType":"LS68-MSU-III-B","bdMaterialNo":"CBSWI-JCA0790B","bdMaterialName":"LS68-MSU-III-B","productionQuantity":"1","typeDscr":"","depName":"制造中心-装配部-高端","startDate":"2016-08-17 00:00:00.0","endDate":"2016-08-22 00:00:00.0","activeOSNo":"","remark":"1*1","swVersion":""},{"workOrderNo":"SC20160810103","workOrderLineNo":"4","u8OrderNo":"021607102","u8LineNo":"11","productNo":"CBPOW-POW0112A","productType":"英文中性化LS68-PWR-AC-600","bdMaterialNo":"CBPOW-POW0112A","bdMaterialName":"英文中性化LS68-PWR-AC-600","productionQuantity":"2","typeDscr":"","depName":"制造中心-装配部-高端","startDate":"2016-08-17 00:00:00.0","endDate":"2016-08-22 00:00:00.0","activeOSNo":"","remark":"1*2","swVersion":""},{"workOrderNo":"SC20160810103","workOrderLineNo":"5","u8OrderNo":"021607102","u8LineNo":"12","productNo":"CBSWI-JCA0774B","productType":"LS68-12GE-TX/SFP-V3","bdMaterialNo":"CBSWI-JCA0774B","bdMaterialName":"LS68-12GE-TX/SFP-V3","productionQuantity":"1","typeDscr":"","depName":"制造中心-装配部-高端","startDate":"2016-08-17 00:00:00.0","endDate":"2016-08-22 00:00:00.0","activeOSNo":"","remark":"1*1","swVersion":""}]

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2017/1/19 17:28:00 [显示全部帖子]

类似与下面的。嵌套了好多层,也是用同样的代码可以实现?还是有区别?
{"id":50,"createDate":"2016-12-20","shipDate":"2016-12-21","isSyncU8":true,"isGenerate":"","isPause":"","u8No":"Test201612160011612004","u8OrderNos":"Test20161216001","dlid":"","remark":"","createEmployee":"test@bdcom.com.cn","BDinvoiceBody":[{"id":142,"lineNo":6,"u8LineNo":"","info":"CBSWI-JCA0673D/CBSWI-JCA0807B/CBSWI-JCA0833D/CBPOW-POW0062A/CBSWI-JCA0837B/BYSWI-SWI1217A/","iall":{"id":96,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[{"id":16,"deliveryCount":10,"info":"","whpiDl":{"id":6,"workIdentify":"@1970","workNo":"u8Work1970","workLineNo":"0","u8OrderNo":"u8Order1970","u8LineNo":"0","workRemark":"","workDate":"2016-12-20","permitCount":123,"whpiFlowId_Counts":"","deliverCounts":"10,10,10,10,","info":"","wareHouse":{"id":8,"wareHouseCode":"30","wareHouseName":"成品库"},"canUseNum":83,"whpiDetails":{"id":26,"flow_id":"SWBR-20161220001"}}}],"flow_id":"SWB-20161219001","group_flag":"11744","appId":27},"orderDetail":{"id":11744,"lineNo":3,"productNo":"BYSWI-SWI1217A","productType":"TOM5009-Chassis-PLUS","sumNo":100000,"relationSum":0,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"3","orderStatus":"","bdMaterialNo":"CBSWI-SWI1353A","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":0,"satisfy":true,"oemNo":"oeout9GAEe00101","tableName":"oeout9GAEe00101-博瀛通信产品化申请表(TOM5009-Chassis-PLUS^LS6810-Chassis-PLUS)(01).xls","bdMaterialName":"LS6810-Chassis-PLUS","deliverCount":"","activeOSNo":"oeout9GAEe00101","isUpdate":"","isDelete":"","autoId":"129472","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":-1,"childs":[]}},{"id":143,"lineNo":1,"u8LineNo":"","info":"","iall":{"id":97,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[],"flow_id":"SWB-20161219001","group_flag":"11744","appId":21},"orderDetail":{"id":11738,"lineNo":4,"productNo":"CBSWI-JCA0673D","productType":"英文中性化GSFP-LX-10-D","sumNo":800000,"relationSum":8,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"4","orderStatus":"","bdMaterialNo":"CBSWI-JCA0436D","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":24,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"GSFP-LX-10-D","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129468","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":11742,"childs":[]}},{"id":144,"lineNo":2,"u8LineNo":"","info":"","iall":{"id":98,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[],"flow_id":"SWB-20161219001","group_flag":"11744","appId":22},"orderDetail":{"id":11739,"lineNo":2,"productNo":"CBSWI-JCA0807B","productType":"中文中性化LS68-MSU-III-B","sumNo":200000,"relationSum":2,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"2","orderStatus":"","bdMaterialNo":"CBSWI-JCA0790B","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":2,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"LS68-MSU-III-B","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129471","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":11744,"childs":[]}},{"id":145,"lineNo":4,"u8LineNo":"","info":"","iall":{"id":100,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[],"flow_id":"SWB-20161219001","group_flag":"11744","appId":24},"orderDetail":{"id":11741,"lineNo":7,"productNo":"CBPOW-POW0062A","productType":"中文中性化LS68-PWR-AC-1000","sumNo":100000,"relationSum":1,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"7","orderStatus":"","bdMaterialNo":"CBPOW-POW0047A","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":2,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"LS68-PWR-AC-1000","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129469","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":11744,"childs":[]}},{"id":146,"lineNo":3,"u8LineNo":"","info":"","iall":{"id":99,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[],"flow_id":"SWB-20161219001","group_flag":"11744","appId":23},"orderDetail":{"id":11740,"lineNo":5,"productNo":"CBSWI-JCA0833D","productType":"中文中性化LS68-24GE-TX-V3","sumNo":100000,"relationSum":1,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"5","orderStatus":"","bdMaterialNo":"CBSWI-JCA0773D","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":8,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"LS68-24GE-TX-V3","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129474","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":11744,"childs":[]}},{"id":147,"lineNo":5,"u8LineNo":"","info":"","iall":{"id":101,"delivery_sum":10,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"汇通到付","delviery_Date":"2016-12-21","isSyncU8":true,"u8No":"","remark":"","specialGoodsFilePath":"","houseId":8,"wareHouseCode":"30","wareHouseName":"成品库","workInfos":[],"flow_id":"SWB-20161219001","group_flag":"11744","appId":25},"orderDetail":{"id":11742,"lineNo":6,"productNo":"CBSWI-JCA0837B","productType":"中文中性化LS68-12GE-TX/SFP-V3","sumNo":100000,"relationSum":1,"packageType":"","warranty":"","requireDate":"2017-01-08","conDate":"","onlineDate":"","overDate":"","preEndDate":"2017-03-12","swVersion":"同博达交换","workOrderNo":"","lineFlag":"","u8OrderNo":"Test20161216001","u8LineNo":"6","orderStatus":"","bdMaterialNo":"CBSWI-JCA0774B","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":8,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"LS68-12GE-TX/SFP-V3","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129470","isosid":"","detailStatus":"3N,2,3Y,3N,2,3Y","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4689,"groupId":11744,"parentDetail":11744,"childs":[]}}]}

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2017/2/9 17:29:00 [显示全部帖子]

这是json数据 {"id":85,"createDate":"2017-02-09","shipDate":"2030-01-01","isSyncU8":true,"isGenerate":"","isPause":"","u8No":"BD1702015","u8OrderNos":"011702007","dlid":"","remark":"","createEmployee":"test@bdcom.com.cn","BDinvoiceBody":[{"id":251,"lineNo":2,"u8LineNo":"","info":"CBWIR-WAC0013D/","iall":{"id":361,"delivery_sum":1,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"其它快递到付","delviery_Date":"2030-01-01","isSyncU8":true,"u8No":"","remark":"asdfsdfsfd","specialGoodsFilePath":"","houseId":"","wareHouseCode":"","workInfos":[{"id":162,"deliveryCount":1,"info":"","whpiDl":{"id":30,"workIdentify":"@1970","workNo":"u8Work1970","workLineNo":"0","u8OrderNo":"u8Order1970","u8LineNo":"0","workRemark":"","workDate":"2017-02-09","permitCount":5,"whpiFlowId_Counts":"","deliverCounts":"1,1,1,1,1,","info":"","wareHouse":{"id":8,"wareHouseCode":"30","wareHouseName":"成品库"},"canUseNum":0,"whpiDetails":{"id":46,"flow_id":"SWBR-20170209002"}}}],"wareHouseName":"成品库","flow_id":"SWB-20170209001","group_flag":"11784","appId":58},"orderDetail":{"id":11784,"lineNo":1,"productNo":"CBWIR-WAC0013D","productType":"BDCOM WSC6100-X1024B","sumNo":100,"relationSum":0,"packageType":"","warranty":"","requireDate":"2020-01-01","conDate":"","onlineDate":"","overDate":"","preEndDate":"2020-01-01","swVersion":"同博达","workOrderNo":"","lineFlag":"","u8OrderNo":"011702007","u8LineNo":"1","orderStatus":"","bdMaterialNo":"CBWIR-WAC0013D","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":0,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"BDCOM WSC6100-X1024B","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129545","isosid":"","detailStatus":"","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4700,"groupId":11784,"parentDetail":-1,"childs":[]}},{"id":252,"lineNo":1,"u8LineNo":"","info":"SMCAR-CAR0516A/","iall":{"id":360,"delivery_sum":1,"delivery_Address":"居里路123号","delivery_Company":"上海博达","delivery_Customer":"abc","delivery_Phone":"13922234963","delivery_Type":"其它快递到付","delviery_Date":"2030-01-01","isSyncU8":true,"u8No":"","remark":"asdfsdfsfd","specialGoodsFilePath":"","houseId":"","wareHouseCode":"","workInfos":[{"id":161,"deliveryCount":1,"info":"","whpiDl":{"id":31,"workIdentify":"@1970","workNo":"u8Work1970","workLineNo":"0","u8OrderNo":"u8Order1970","u8LineNo":"0","workRemark":"","workDate":"2017-02-09","permitCount":7,"whpiFlowId_Counts":"","deliverCounts":"1,1,1,1,2,","info":"","wareHouse":{"id":8,"wareHouseCode":"30","wareHouseName":"成品库"},"canUseNum":1,"whpiDetails":{"id":47,"flow_id":"SWBR-20170209003"}}}],"wareHouseName":"成品库","flow_id":"SWB-20170209001","group_flag":"11785","appId":59},"orderDetail":{"id":11785,"lineNo":2,"productNo":"SMCAR-CAR0516A","productType":"HIC-1GE-TX/SFP","sumNo":100,"relationSum":0,"packageType":"","warranty":"","requireDate":"2020-01-01","conDate":"","onlineDate":"","overDate":"","preEndDate":"2020-01-01","swVersion":"同博达","workOrderNo":"","lineFlag":"","u8OrderNo":"011702007","u8LineNo":"2","orderStatus":"","bdMaterialNo":"SMCAR-CAR0516A","specialNo":"","specialType":"","info":"","buyer":"","maxRelationSum":0,"satisfy":true,"oemNo":"","tableName":"","bdMaterialName":"HIC-1GE-TX/SFP","deliverCount":"","activeOSNo":"","isUpdate":"","isDelete":"","autoId":"129546","isosid":"","detailStatus":"","selectFlag":"","preparePlan":"","lockProductNum":"","parentOrder":4700,"groupId":11785,"parentDetail":-1,"childs":[]}}]}
这是我运行出错的代码
Dim Multi As String = "{""id"":85,""createDate"":""2017-02-09"",""shipDate"":""2030-01-01"",""isSyncU8"":true,""isGenerate"":"""",""isPause"":"""",""u8No"":""BD1702015"",""u8OrderNos"":""011702007"",""dlid"":"""",""remark"":"""",""createEmployee"":""test@bdcom.com.cn"",""BDinvoiceBody"":[{""id"":251,""lineNo"":2,""u8LineNo"":"""",""info"":""CBWIR-WAC0013D/"",""iall"":{""id"":361,""delivery_sum"":1,""delivery_Address"":""居里路123号"",""delivery_Company"":""上海博达"",""delivery_Customer"":""abc"",""delivery_Phone"":""13922234963"",""delivery_Type"":""其它快递到付"",""delviery_Date"":""2030-01-01"",""isSyncU8"":true,""u8No"":"""",""remark"":""asdfsdfsfd"",""specialGoodsFilePath"":"""",""houseId"":"""",""wareHouseCode"":"""",""workInfos"":[{""id"":162,""deliveryCount"":1,""info"":"""",""whpiDl"":{""id"":30,""workIdentify"":""@1970"",""workNo"":""u8Work1970"",""workLineNo"":""0"",""u8OrderNo"":""u8Order1970"",""u8LineNo"":""0"",""workRemark"":"""",""workDate"":""2017-02-09"",""permitCount"":5,""whpiFlowId_Counts"":"""",""deliverCounts"":""1,1,1,1,1,"",""info"":"""",""wareHouse"":{""id"":8,""wareHouseCode"":""30"",""wareHouseName"":""成品库""},""canUseNum"":0,""whpiDetails"":{""id"":46,""flow_id"":""SWBR-20170209002""}}}],""wareHouseName"":""成品库"",""flow_id"":""SWB-20170209001"",""group_flag"":""11784"",""appId"":58},""orderDetail"":{""id"":11784,""lineNo"":1,""productNo"":""CBWIR-WAC0013D"",""productType"":""BDCOM WSC6100-X1024B"",""sumNo"":100,""relationSum"":0,""packageType"":"""",""warranty"":"""",""requireDate"":""2020-01-01"",""conDate"":"""",""onlineDate"":"""",""overDate"":"""",""preEndDate"":""2020-01-01"",""swVersion"":""同博达"",""workOrderNo"":"""",""lineFlag"":"""",""u8OrderNo"":""011702007"",""u8LineNo"":""1"",""orderStatus"":"""",""bdMaterialNo"":""CBWIR-WAC0013D"",""specialNo"":"""",""specialType"":"""",""info"":"""",""buyer"":"""",""maxRelationSum"":0,""satisfy"":true,""oemNo"":"""",""tableName"":"""",""bdMaterialName"":""BDCOM WSC6100-X1024B"",""deliverCount"":"""",""activeOSNo"":"""",""isUpdate"":"""",""isDelete"":"""",""autoId"":""129545"",""isosid"":"""",""detailStatus"":"""",""selectFlag"":"""",""preparePlan"":"""",""lockProductNum"":"""",""parentOrder"":4700,""groupId"":11784,""parentDetail"":-1,""childs"":[]}},{""id"":252,""lineNo"":1,""u8LineNo"":"""",""info"":""SMCAR-CAR0516A/"",""iall"":{""id"":360,""delivery_sum"":1,""delivery_Address"":""居里路123号"",""delivery_Company"":""上海博达"",""delivery_Customer"":""abc"",""delivery_Phone"":""13922234963"",""delivery_Type"":""其它快递到付"",""delviery_Date"":""2030-01-01"",""isSyncU8"":true,""u8No"":"""",""remark"":""asdfsdfsfd"",""specialGoodsFilePath"":"""",""houseId"":"""",""wareHouseCode"":"""",""workInfos"":[{""id"":161,""deliveryCount"":1,""info"":"""",""whpiDl"":{""id"":31,""workIdentify"":""@1970"",""workNo"":""u8Work1970"",""workLineNo"":""0"",""u8OrderNo"":""u8Order1970"",""u8LineNo"":""0"",""workRemark"":"""",""workDate"":""2017-02-09"",""permitCount"":7,""whpiFlowId_Counts"":"""",""deliverCounts"":""1,1,1,1,2,"",""info"":"""",""wareHouse"":{""id"":8,""wareHouseCode"":""30"",""wareHouseName"":""成品库""},""canUseNum"":1,""whpiDetails"":{""id"":47,""flow_id"":""SWBR-20170209003""}}}],""wareHouseName"":""成品库"",""flow_id"":""SWB-20170209001"",""group_flag"":""11785"",""appId"":59},""orderDetail"":{""id"":11785,""lineNo"":2,""productNo"":""SMCAR-CAR0516A"",""productType"":""HIC-1GE-TX/SFP"",""sumNo"":100,""relationSum"":0,""packageType"":"""",""warranty"":"""",""requireDate"":""2020-01-01"",""conDate"":"""",""onlineDate"":"""",""overDate"":"""",""preEndDate"":""2020-01-01"",""swVersion"":""同博达"",""workOrderNo"":"""",""lineFlag"":"""",""u8OrderNo"":""011702007"",""u8LineNo"":""2"",""orderStatus"":"""",""bdMaterialNo"":""SMCAR-CAR0516A"",""specialNo"":"""",""specialType"":"""",""info"":"""",""buyer"":"""",""maxRelationSum"":0,""satisfy"":true,""oemNo"":"""",""tableName"":"""",""bdMaterialName"":""HIC-1GE-TX/SFP"",""deliverCount"":"""",""activeOSNo"":"""",""isUpdate"":"""",""isDelete"":"""",""autoId"":""129546"",""isosid"":"""",""detailStatus"":"""",""selectFlag"":"""",""preparePlan"":"""",""lockProductNum"":"""",""parentOrder"":4700,""groupId"":11785,""parentDetail"":-1,""childs"":[]}}]}"

Dim data As object
Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", Multi)
End With

For Each level1 As object In data
msgbox(level1.id)
    For Each level2 As object In level1.BDinvoiceBody
        For Each level3 As object In level2.workInfos
            For Each level4 As object In level3.whpiDl
                msgbox(level4.workNo)
            Next
        Next
    Next
Next
是json不对呢还是哪里出问题了?

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


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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2017/2/9 17:37:00 [显示全部帖子]

For Each level1 As object In data
msgbox(level1.id)
    'For Each level2 As object In level1.BDinvoiceBody
        'For Each level3 As object In level2.workInfos
            'For Each level4 As object In level3.whpiDl
                'msgbox(level4.workNo)
            'Next
        'Next
    'Next
Next
只取第一次的id,也报这个错误

 回到顶部
总数 11 1 2 下一页