以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  生成json不对  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=124817)

--  作者:煜杭
--  发布时间:2018/9/14 10:37:00
--  生成json不对
Dim jo As New JObject
Dim zbja As New JArray
Dim zbjo As New JObject
zbjo("TableName") = "表A"
Dim zblm() As String = {"rq","ckmc","bz","djh","djzt","leuser"}   \'主表列名
zbjo("columnNames") = New Jarray(zblm)
zbja.Add(zbjo)
jo("MainTables") = zbja
Dim zbcsja As New JArray
Dim zbcsja1 As New JArray
Dim zblz() As String = {"2018/08/16","原材料仓库","备注内容","SJD-20180424039","待启动流程","提交人"}  \'主表传值

Dim zbcsjo1 As New JObject
For Index As Integer = 0 To zblm.Length - 1
    \'MessageBox.Show(zblm(Index))
    zbcsjo1("columnName") = zblm(Index)
    zbcsjo1("Value") = zblz(Index)
    zbcsja1.Add(zbcsjo1)
Next
zbcsja.Add(zbcsja1)
zbjo("ItemLists")  = zbcsja
output.show(jo.ToString)


结果:
{
  "MainTables": [
    {
      "TableName": "表A",
      "columnNames": [
        "rq",
        "ckmc",
        "bz",
        "djh",
        "djzt",
        "leuser"
      ],
      "ItemLists": [
        [
          {
            "columnName": "leuser",             这里应该是日期才对,不知道什么原因
            "Value": "提交人"
          },
          {
            "columnName": "ckmc",
            "Value": "原材料仓库"
          },
          {
            "columnName": "bz",
            "Value": "备注内容"
          },
          {
            "columnName": "djh",
            "Value": "单据号"
          },
          {
            "columnName": "djzt",
            "Value": "待启动流程"
          },
          {
            "columnName": "leuser",
            "Value": "提交人"
          }
        ]
      ]
    }
  ]
}


--  作者:有点蓝
--  发布时间:2018/9/14 11:02:00
--  
For Index As Integer = 0 To zblm.Length - 1
    zbcsjo1 = New JObject
    zbcsjo1("columnName") = zblm(Index)
    zbcsjo1("Value") = zblz(Index)
    zbcsja1.Add(zbcsjo1)
Next

--  作者:煜杭
--  发布时间:2018/9/14 11:09:00
--  
感谢