以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  懵了!没有方向  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=154301)

--  作者:石四
--  发布时间:2020/9/10 15:06:00
--  懵了!没有方向
现在单子上的二维码扫出来的字符是标准的JSON,很好调用。
{"D":"DL0859020090409","S":"S-00008590","W":"1400DPDP","I":[{"I":"23928550","N":"480.0","P":"20200904"},{"I":"23928552","N":"480.0","P":"20200904"},{"I":"24510382","N":"96.0","P":"20200904"},{"I":"24513058","N":"96.0","P":"20200904"}]}

Dim jsonStr=e.Form.Controls("TextBox1").value
Dim jo As JObject = JObject.Parse(jsonStr)
e.Form.Controls("Label1").text=jo("W").Tostring

Dim ja As JArray = jo("I")
Dim msg0 As String=""
Dim msg1 As String=""
For i As Integer = 0 To ja.Count - 1
    Dim jo2 As JObject =ja(i)
    msg0  = jo2("I").Tostring
    msg1  = jo2("N").Tostring
    Tables("test_Table1").AddNew()
    Dim r As Row = Tables("test_Table1").Current
    r("第一列") = msg0
    r("第二列") = msg1
Next

--  作者:石四
--  发布时间:2020/9/10 15:10:00
--  
对方系统准备升级,单子的二维码扫出来变成这种形式:
S1911150593,5500000708,0XR52544,1001-101,R0,5080F-5101101,50.0,20191115,R0,5080F-5101102,50.0,20191115,R0,5080F-5202101,60.0,20191115,R0,5080F-5202102,60.0,20191115,R0,5080F-5205010,50.0,20191115,R0,5080F-5205201,87.0,20191115,

完全不是一个标准的JSON,怎么处理?完全不知从哪下手》
RO相当原来的I那部分。


--  作者:有点蓝
--  发布时间:2020/9/10 15:12:00
--  
使用逗号拆分字符串,至于哪一部分是什么数据应该是找接口方给个说明和规则。问我们没有用的
--  作者:石四
--  发布时间:2020/9/10 15:50:00
--  
不需要接口,但是怎么取值呢?

有办法拆分成这个结果吗?
S1911150593,
5500000708
0XR52544
1001-101
R0,5080F-5101101,50.0,20191115
R0,5080F-5101102,50.0,20191115
R0,5080F-5202101,60.0,20191115
R0,5080F-5202102,60.0,20191115
R0,5080F-5205010,50.0,20191115
R0,5080F-5205201,87.0,20191115

--  作者:有点蓝
--  发布时间:2020/9/10 15:52:00
--  
http://www.foxtable.com/webhelp/topics/0245.htm
--  作者:linyunu1
--  发布时间:2020/9/10 18:49:00
--  
Dim s As String = "S1911150593,5500000708,0XR52544,1001-101,R0,5080F-5101101,50.0,20191115,R0,5080F-5101102,50.0,20191115,R0,5080F-5202101,60.0,20191115,R0,5080F-5202102,60.0,20191115,R0,5080F-5205010,50.0,20191115,R0,5080F-5205201,87.0,20191115"
Dim s1 As String = s.SubString(0,s.IndexOf("R0")-1)
Output.Show(s1)
Dim s2 As String = s.SubString(s.IndexOf("R0")+3).Replace(",R0,","|")
Dim Values() As String = s2.Split("|")
For Index As Integer = 0 To Values.Length - 1
    Output.Show(Values(Index))
Next

--  作者:石四
--  发布时间:2020/9/11 9:13:00
--  
Thanks
--  作者:石四
--  发布时间:2020/9/11 9:15:00
--  
Dim Multi As String = "S1911150593,5500000708,0XR52544,1001-101,R0,5080F-5101101,50.0,20191115,R0,5080F-5101102,50.0,20191115,R0,5080F-5202101,60.0,20191115,R0,5080F-5202102,60.0,20191115,R0,5080F-5205010,50.0,20191115,R0,5080F-5205201,87.0,20191115,"
Multi = Multi.Trim(",")
Dim Values() As String
Values = Multi.split(",")
For Index As Integer = 1 To (Values.Length - 5)/4
    Output.Show(Values(Index * 4+1))
    Output.Show(Values(Index * 4+2))
Next

幸好我数学及格图片点击可在新窗口打开查看