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

查看:143
本文介绍了使用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是一种分层数据格式,因此如Peter所建议的那样,使用正则表达式和Split()不会让您走得太远.

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

如果环境允许CreateObject(),则可以使用以另一种语言编写的现成的COMponent(例如,将标准json2.js包装为.WSC或COM来启用.NET DLL).另一种选择是通过Microsoft脚本控件利用另一种语言.这种方法的缺点是,您必须处理另一种语言提供的对象/数组(某些提示可以在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天全站免登陆