以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  生成josn出现重复,怎么修正呢?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=189083)

--  作者:cnsjroom
--  发布时间:2023/11/9 15:09:00
--  生成josn出现重复,怎么修正呢?
当前代码如下:


Dim cmd As New SQLCommand
cmd.C \'记得设置数据源名称
cmd.CommandText = "Se lect [_Identify],[_SortKey],卷宗名称,材料类别,材料名称,材料附件,材料guid From {View_juanzongcailiao} where 案件id=\'2b8ff1fa-2ed5-4cfd-ad3c-748616441a13\' "
Dim dt As DataTable = cmd.ExecuteReader
Dim drs As List(Of DataRow) = dt.Se lect("材料名称 is not null and 材料guid is not null", "_SortKey")
Output.Show(drs.Count)
Dim j As New JObject
Dim ja As New JArray
For Each dr As DataRow In drs
    Dim jo As New JObject
    jo("id") = dr("材料guid").ToString
    jo("label") = dr("卷宗名称").ToString
\'    jo("parentId") = "0"
\'    jo("fujian") = dr("材料附件").ToString
    \'        jo("children") = GetNavigation1(dt, dr)
    If Not ja.Contains(jo) Then
        ja.Add(jo)
    End If
Next
Output.Show(ja.ToString)

生成josn出现重复,怎么修正呢?  想以材料guid为唯一值,一个值只出现一次!

28
[
  {
    "id": "be125946-3411-4114-b074-d75fd9c99f35",
    "label": "333"
  },
  {
    "id": "be125946-3411-4114-b074-d75fd9c99f35",
    "label": "333"
  },
  {
    "id": "799c52ae-abe5-41be-be17-71baea6dd1bf",
    "label": "333"
  },
  {
    "id": "799c52ae-abe5-41be-be17-71baea6dd1bf",
    "label": "333"
  },
  {
    "id": "5b488b48-fe55-4e1b-ba91-4c1c3e4f4d51",
    "label": "333"
  },
  {
    "id": "5b488b48-fe55-4e1b-ba91-4c1c3e4f4d51",
    "label": "333"
  },
  
[此贴子已经被作者于2023/11/9 15:41:20编辑过]

--  作者:有点蓝
--  发布时间:2023/11/9 15:15:00
--  
cmd.CommandText = "Select 卷宗名称,材料guid,_SortKey From {View_juanzongcailiao} where 案件id=\'2b8ff1fa-2ed5-4cfd-ad3c-748616441a13\' and 材料名称 is not null and 材料guid is not null"
Dim dt As DataTable = cmd.ExecuteReader
Dim j As New JObject
Dim ja As New JArray
For Each ss As string() In  dt.getbalues("材料guid|卷宗名称", "_SortKey")
    Dim jo As New JObject
    jo("id") = ss(0)
    jo("label") = ss(1)
[此贴子已经被作者于2023/11/9 15:19:13编辑过]

--  作者:cnsjroom
--  发布时间:2023/11/9 15:41:00
--  回复:(有点蓝)cmd.CommandText = "Select 卷宗名称...
如何实现根据label进行节点的调整,让label作为第一节点 然后以name作为第二节点呢?谢谢老师

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

Dim cmd As New SQLCommand
cmd.Conn ec tio nName = "主数据源" \'记得设置数据源名称
cmd.CommandText = "Sel ect [_Identify],[_SortKey],卷宗名称,材料类别,材料名称,材料附件,材料guid From {View_juanzongcailiao} where 案件id=\'2b8ff1fa-2ed5-4cfd-ad3c-748616441a13\'and 材料名称 is not null and 材料guid is not null "
Dim dt As DataTable = cmd.ExecuteReader
Dim ja As New JArray
For Each ss As String() In dt.getvalues("材料guid|卷宗名称|材料名称|材料附件")
    Dim jo As New JObject
    jo("id") = ss(0)
    jo("label") = ss(1)
    jo("name") = ss(2)
    jo("parentId") = "0"
\'    jo("fujian") = ss(3)
    Dim json As String = ss(3)
    Dim jsonObjects As JArray = JArray.Parse(json) 
    Dim firstJsonObject As JObject = jsonObjects(0) 
    Dim urlValue As String = firstJsonObject("url")
    Output.Show("http://localhost:8088" & urlValue)
\'      jo("children") = "123"
    If Not ja.Contains(jo("id")) Then
        ja.Add(jo)
    End If
Next
Output.Show(ja.ToString)


--  作者:有点蓝
--  发布时间:2023/11/9 15:51:00
--  
For Each ss As String In dt.getvalues("卷宗名称")
生成第一节点
     For Each ss2 As String In dt.getvalues("材料guid|材料名称","卷宗名称=\'" & ss & "\'")
     生成第2节点