ASPPY.json

The ASPPY.json namespace provides fast, native JSON serialization and deserialization for VBScript.

Instead of relying on slow, third-party VBScript parser classes, ASPPY automatically maps VBScript arrays and Scripting.Dictionary objects to native Python lists and dicts, feeding them through Python's robust json module.

Methods

Method Description
Encode(value, [pretty=False]) Takes a VBScript variable (string, integer, boolean, Array, or Scripting.Dictionary) and serializes it to a JSON string. If pretty is True, the JSON is indented.
Decode(json_string) Parses a JSON string and returns a VBScript representation. JSON arrays become VBScript Arrays, and JSON objects become Scripting.Dictionary objects.

Sample Code: Encoding

<%
Dim dict, jsonString

' Create a standard Scripting.Dictionary
Set dict = Server.CreateObject("Scripting.Dictionary")
dict.Add "name", "ASPPY Framework"
dict.Add "version", 1.0
dict.Add "active", True

' Nest an array
dict.Add "features", Array("JSON", "Crypto", "PDF", "Image", "Zip")

' Encode it to a JSON string with pretty formatting
jsonString = ASPPY.json.Encode(dict, True)

Response.Write "<h5>Encoded JSON:</h5>"
Response.Write "<pre>" & Server.HTMLEncode(jsonString) & "</pre>"
%>

Sample Code: Decoding

<%
Dim rawJson, decodedDict, features, feature

rawJson = "{""user"": ""john_doe"", ""age"": 30, ""active"": true, ""roles"": [""admin"", ""editor""]}"

' Decode the JSON string
Set decodedDict = ASPPY.json.Decode(rawJson)

Response.Write "<b>User:</b> " & decodedDict("user") & "<br>"
Response.Write "<b>Age:</b> " & decodedDict("age") & "<br>"

If decodedDict("active") Then
    Response.Write "<b>Status:</b> Active<br>"
End If

features = decodedDict("roles")
Response.Write "<b>Roles:</b> " & Join(features, ", ")
%>
Why use ASPPY.json? Traditional classic ASP JSON parsers rely on complex regular expressions in VBScript and are notoriously slow on large datasets. ASPPY hands off this operation to C-optimized underlying libraries, resulting in near-instantaneous encoding and decoding even for massive payloads.