以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教这个格式如何生成json  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=160869)

--  作者:liufucan
--  发布时间:2021/2/24 14:19:00
--  请教这个格式如何生成json
var arr = [
{cn:"test",table:"补款表",re_col:"房号",re_v:row["房号"]},
{cn:"test",table:"车位成交表",re_col:"房号",re_v:row["房号"]},
{cn:"test",table:"地下室成交表",re_col:"房号",re_v:row["房号"]},
{cn:"test",table:"签约表",re_col:"房号",re_v:row["房号"]

}

以下代码报错:
无法将类型为“System.String”的对象强制转换为类型“Newtonsoft.Json.Linq.JToken”。

Dim drs As List(of DataRow)  = DataTables("关联表").SQLSelect("父表 = \'" & e.Values("q") & "\'")
For Each dr As DataRow In drs
            arr.Add(new jobject)
            arr(i)("cn") = "test".ToString
arr(i)("table") = dr("子表").ToString
arr(i)("re_col") = dr("父表关联列").ToString
arr(i)("re_v")=cstr("Row[""" & dr("子表关联列") & """]")
            i = i + 1
        Next
Dim count2=DataTables("关联表").SQLCompute("Count(*)", "父表 = \'" & e.Values("q") & "\'")
        obj("count") = count2.ToString
        obj("children") = arr

        e.WriteString(CompressJson(obj))

--  作者:有点蓝
--  发布时间:2021/2/24 14:36:00
--  
For Each dr As DataRow In drs
Dim jo As New JObject
jo("cn") = "test"
jo("table") = dr("子表").ToString
……
arr.Add(jo)
next