Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decode/Encode JSON with VBScript

Tags:

json

vbscript

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.

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.

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

like image 990
Stefan Brendle Avatar asked Aug 28 '12 06:08

Stefan Brendle


2 Answers

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

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).

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.

like image 138
Ekkehard.Horner Avatar answered Sep 18 '22 22:09

Ekkehard.Horner


How about doing this with ASPJSON?
Available from http://www.aspjson.com/

I'm about to use this as a solution for a very old site to send an ajax call (using Jquery) with the encoded data to a MongoDB, for testing.

like image 31
Logan Avatar answered Sep 18 '22 22:09

Logan