Skip to content Skip to sidebar Skip to footer

List Keys In Jscript Object Using Vbscript (classic Asp)

I am using the JSON2 script in an asp page to parse JSON post data. After parsing the data, I have an object in VBScript that allows for notations such as: jsonData.key I wish to p

Solution 1:

You need to enumerate the property names of the object however this is a very alien thing to do in VBScript. You will need to build some other Jscript functions to assist converting the object into something more easily consumed in VBScript.

If the data is really as simplistic as the example in the question then you could use this function:-

functiontoDictionary(o)
{
     var result = Server.CreateObject("Scripting.Dictionary");
     for (var key in o)
         result.Add(key, o[key]);
     return result;
}

Now in VBScript:-

Dim myData: Set myData = toDictionary(jsonData);

ForEachKeyIn myData
   '' // Each Key is a property for jsonDataNext

Post a Comment for "List Keys In Jscript Object Using Vbscript (classic Asp)"