使用 VBScript 解码/编码 JSON [英] Decode/Encode JSON with VBScript

查看:23
本文介绍了使用 VBScript 解码/编码 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ERP 系统的快速开发工具,它只允许使用 vbscript.我正在尝试使用 VBS 创建一个简单的 AJAX 请求.这与Microsoft.XMLHTTP"对象一起使用.

I've got a rapid development tool for an ERP-system, which allows only vbscript. I'm trying to create a simple AJAX-Request with VBS. That worked with the "Microsoft.XMLHTTP"-object.

下一步是使用 json 从网络服务器接收数据.但是在 VBS 中似乎没有像json_decode"这样的功能.

Next step is to receive data from a webserver using json. But in VBS there seems to be no function like "json_decode" oder other.

有人知道解决办法吗?或者是开发我自己的 json 函数的唯一选择?

Does anyone know a solution? Or is the only option to develop my own json-function?

推荐答案

因为 JSON 是一种分层数据格式,所以使用正则表达式和 Split(),正如 Peter 所提议的,不会让你走得更远.

As JSON is a hierarchical data format, using Regular expressions and Split(), as Peter proposed, won't get you far.

如果您的环境允许 CreateObject() 您可以使用用另一种语言编写的现成组件(例如将标准 json2.js 包装在 .WSC 或 COM 中启用 .NET DLL).另一种选择是通过 Microsoft Script Control 来利用另一种语言.这种方法的缺点是您必须处理其他语言提供的对象/数组(一些提示可以在 Peter 提到的主题中找到).

If your environment allows CreateObject() you may be able to use a ready made COMponent written in another language (e.g. wrap the standard json2.js in a .WSC or COM enable a .NET DLL). Another option would be to harness another language via the Microsoft Script Control. The con of this approach is that you'll have to deal with the objects/arrays delivered by the other language (some hints are to be found in the topic Peter refered to).

可以在此处找到纯 VBScript 解决方案.我无法阅读文档,但代码可以编译并有效"用于简单的测试用例 - YMMV.

A pure VBScript solution can be found here. I can't read the documentation, but the code compiles and 'works' for simple test cases - YMMV.

这篇关于使用 VBScript 解码/编码 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆