vbscript [.net]将2-Dim数组转换为List然后转换为JSON

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript [.net]将2-Dim数组转换为List然后转换为JSON相关的知识,希望对你有一定的参考价值。

'*** CREATE 2-DIMENSIONAL ARRAY
Dim resultsArray As String()() = New String(0)() {}
ReDim Preserve resultsArray(runCount)
resultsArray(runCount) = New String() { _
    nameId, _
    name, _
    itemsTotalYayVoteCount, _
    itemsTotalMatchupCount, _
    buzzPoint _
}

'*** CONVERT TO LIST
Dim resultsList As New List(Of Object)()
For i = 0 To resultsArray.GetUpperBound(0)
    Dim colList As New Dictionary(Of String, Object)()
    colList.Add("NameID", resultsArray(i)(0))
    colList.Add("Name", resultsArray(i)(1))
    colList.Add("TotalYayVoteCount", resultsArray(i)(2))
    colList.Add("TotalMatchupCount", resultsArray(i)(3))
    colList.Add("BuzzPoint", resultsArray(i)(4))
    resultsList.Add(colList)
Next

'*** CONVERT LIST TO JSON USING Newtonsoft.Json
JsonArray = New ArrayList()
JsonArray.Add(New With { _
    .Response = "ok" _
})
JsonArray.Add(New With { _
    .Results = resultsList _
})
Dim JsonResponse As String = JsonConvert.SerializeObject(JsonArray)

以上是关于vbscript [.net]将2-Dim数组转换为List然后转换为JSON的主要内容,如果未能解决你的问题,请参考以下文章

将 Staad 与 VBS 一起使用(将 VBA 文档转换为 VBscript)

vbscript将word doc转换为pdf

vbscript 将美元金额转换为文本(例如:用于支票)

.NET将XML转换成数组问题

vbscript中怎样把gb2312转换为UTF-8编码?

VBSCRIPT PPT转换脚本