将 VBA 数组转换为 JSON 数组

发布于 2024-11-02 10:30:02 字数 355 浏览 1 评论 0原文

我正在努力将 VBA 中的数组转换为 JSON。互联网上的大部分信息都是相反的。以前有人这样做过吗?你还有这个功能吗?

我需要在 VBA (excel) 中获取关联数组并将其转换为 JSON,以便我可以在我的网站上的 javascript 中使用它。

结构

cars ['BMW'][0]['model'] = 'Series 5'
cars ['BMW'][0]['year'] = 2000
cars ['BMW'][0]['shape'] = 'hatch'
cars ['BMW'][0]['doors'] = 5
cars ['BMW'][1]['model'] = 'Series 3'
......

I am struggling to convert an array in VBA to JSON. Most of the info on the internet is for the reverse. Has anyone done this before? Do you still have the function?

I need to take an associative array in VBA (excel) and convert it to JSON so I can use it in javascript on my site.

Structure

cars ['BMW'][0]['model'] = 'Series 5'
cars ['BMW'][0]['year'] = 2000
cars ['BMW'][0]['shape'] = 'hatch'
cars ['BMW'][0]['doors'] = 5
cars ['BMW'][1]['model'] = 'Series 3'
......

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲凉≈ 2024-11-09 10:30:02

对象文字的 Javascript 数组:

   [{make:'BMW',model:'Series 5',year:2000,shape:'hatch',doors:5},
    {make:'BMW',model:'Series 3',year:2001,shape:'hatch',doors:5}]

可能的 JSON 等效项:

    {"cars":[{"make":"BMW","model":"Series 5","year":2000,"shape":"hatch","doors":5},
     {"make":"BMW","model":"Series 3","year":2001,"shape":"hatch","doors":5}]}

除非您问不同的问题?

Javascript array of object literals:

   [{make:'BMW',model:'Series 5',year:2000,shape:'hatch',doors:5},
    {make:'BMW',model:'Series 3',year:2001,shape:'hatch',doors:5}]

Possible JSON equivalent:

    {"cars":[{"make":"BMW","model":"Series 5","year":2000,"shape":"hatch","doors":5},
     {"make":"BMW","model":"Series 3","year":2001,"shape":"hatch","doors":5}]}

Unless you're asking a different question?

巴黎夜雨 2024-11-09 10:30:02

假设这是一个包含行和列的 Excel 电子表格,您的 JSON 结构将如下所示。

[[r1c1, r1c2, r1c3, r1c4, r1c5],
 [r2c1, r2c2, r2c3, r2c4, r2c5],
 [r3c1, r3c2, r3c3, r3c4, r3c5],
 [r4c1, r4c2, r4c3, r4c4, r4c5],
 [r5c1, r5c2, r5c3, r5c4, r5c5]]

假设您有 5 行和 5 列。 (r1c1 是第 1 行、第 1 列的单元格)

Assuming this is an Excel Spreadsheet with rows and columns, your JSON structure will look something like.

[[r1c1, r1c2, r1c3, r1c4, r1c5],
 [r2c1, r2c2, r2c3, r2c4, r2c5],
 [r3c1, r3c2, r3c3, r3c4, r3c5],
 [r4c1, r4c2, r4c3, r4c4, r4c5],
 [r5c1, r5c2, r5c3, r5c4, r5c5]]

This assumes you have 5 rows and 5 columns. (r1c1 is the cell at row1,column1)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文