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?
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.
You should better roll out your own based on a query here on json and asp. Like eg this one Any good libraries for parsing JSON in Classic ASP? Most of the time json2 library is used but this is based on jscript so no option for you. Also most of the time this kind of JSON has a fixed structure so it should not be so difficult to parse with a Regularexpression like i demonstrated in a few answer like the one above. You could publish some of your JSON so that we can test it with some routines.
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.
Check out https://github.com/rcdmk/aspJSON
Not sure if this has any relation to www.ASPJSON.com (now defunct) mentioned in Logan's answer.
I had a similar problem so I wrote a JSONtoXML function in VBScript for one of my projects. No warranties on this script (it's provided as-is and has known limitations such as not handling all types of escape sequences):