I am trying to consume a web service in VB6. The service - which I control - currently can return a SOAP/XML message or JSON. I am having a really difficult time figuring out if VB6's SOAP type (version 1) can handle a returned object - as opposed to simple types like string, int, etc. So far I cannot figure out what I need to do to get VB6 to play with returned objects.

所以我想我可以将Web服务中的响应序列化为JSON字符串.VB6是否存在JSON解析器?

推荐答案

查看JSON.org以获得多种不同语言的JSON解析器的最新列表(见主页底部).在 compose 本文时,您将看到指向几个不同JSON解析器的链接,但只有一个用于VB6/VBA(其他为.NET):

  • VB-JSON

    • 当我试图下载压缩文件时,Windows显示数据已损坏.不过,我还是用7-zip把文件拿出来了.原来,Windows无法将zip文件中的主"文件夹"识别为文件夹,7-zip可以看到主"文件夹"的内容,因此您可以打开它,然后相应地解压缩文件.
    • The actual syntax for this VB JSON library is really simple:

      Dim p As Object
      Set p = JSON.parse(strFormattedJSON)
      
      'Print the text of a nested property '
      Debug.Print p.Item("AddressClassification").Item("Description")
      
      'Print the text of a property within an array '
      Debug.Print p.Item("Candidates")(4).Item("ZipCode")
      
    • Note: I had to add the "Microsoft Scripting Runtime" and "Microsoft ActiveX Data Objects 2.8" library as references via Tools > References in the VBA editor.
    • Note: VBJSON code is actually based on a google code project vba-json. However, VBJSON promises several bug fixes from the original version.

Json相关问答推荐

如何使用表键名称GROUP_BY

nlohmann json:为什么我会得到一个解析错误?

使用 jq 重新格式化 JSON 输出

JOLT分裂和数组数据

将JSON行转换为TSV格式, for each 数组项生成单独的行

如何在JQ中展平多维数组

使用 jq 和脚本 bash 映射两个 json

使用 serde 和 csv crates 将嵌套的 json 对象序列化为 csv

如何将该 JSON 解析为 Kotlin 类?

ORA-01422: 精确提取返回的行数超过了与 json 对象组合的请求数

我无法在 Go - Gin 中解析日期/时间

如何限制resolveJsonModule的范围?

将嵌套的 JSON 对象规范化为 Pandas 数据框

如何使用 CORS 实现 JavaScript Google Places API 请求

在 Bash 中访问 JSON 对象 - 关联数组/列表/另一个模型

JSON Schema:验证数字或空值

Microsoft.Net.Http 与 Microsoft.AspNet.WebApi.Client

如何使用 Json.NET 反序列化可以是两种不同数据类型的 JSON 属性

YAML 将 5e-6 加载为字符串而不是数字

在 .NET 中缩小缩进的 JSON 字符串