<%
' ===========================================
' PERFORMANCE TRACKING & INITIALIZATION
' ===========================================
Dim startTime, parseTime, endTime, totalTime
Dim json, parsedData, testResults
startTime = Timer
Set json = CreateRabbitJSON()
Set testResults = Server.CreateObject("Scripting.Dictionary")
' Demo configuration
Dim demoSampleFile, demoApiUrl1, demoApiUrl2
demoSampleFile = "sample-data.json"
demoApiUrl1 = "https://jsonplaceholder.typicode.com/posts/1"
demoApiUrl2 = "https://api.github.com/users/octocat"
%>
๐ JSON File Loading Demonstration
<%
' File Loading Test
Dim fileStartTime, fileLoadTime, fileParseTime
fileStartTime = Timer
Dim fso, jsonFile, jsonContent, fileSize
Set fso = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set jsonFile = fso.OpenTextFile(Server.MapPath(demoSampleFile), 1)
If Err.Number = 0 Then
jsonContent = jsonFile.ReadAll()
jsonFile.Close()
fileSize = Len(jsonContent)
fileLoadTime = Timer
' Parse the loaded JSON
Set parsedData = json.Parse(jsonContent)
fileParseTime = Timer
If Not (parsedData Is Nothing) And json.LastError = "" Then
' Successful parse - test access
' Test data access to verify parse success
Dim testCompanyName
' Test data access to verify parse success
testCompanyName = json.GetValue("company.name", "")
If testCompanyName <> "" Then
testResults("fileLoad") = True
testResults("fileLoadTime") = (fileLoadTime - fileStartTime) * 1000
testResults("fileParseTime") = (fileParseTime - fileLoadTime) * 1000
testResults("fileSize") = fileSize
Response.Write "
"
Response.Write "
โ
File Loading & Parse Success
"
Response.Write "File: " & demoSampleFile & "
"
Response.Write "Size: " & FormatNumber(fileSize, 0) & " characters
"
Response.Write "Load Time: " & FormatNumber(testResults("fileLoadTime"), 2) & "ms
"
Response.Write "Parse Time: " & FormatNumber(testResults("fileParseTime"), 2) & "ms
"
Response.Write "Root Sections: " & UBound(json.GetKeys()) + 1 & "
"
Response.Write "Data Verification: " & testCompanyName & ""
Response.Write ""
Else
testResults("fileLoad") = False
Response.Write "
"
Response.Write "
โ Data Access Failed
"
Response.Write "Parse Status: Object created but data access failed
"
Response.Write "Error: " & json.LastError & "
"
Response.Write "Debug: Company name test returned empty"
Response.Write ""
End If
Else
testResults("fileLoad") = False
Response.Write "
"
Response.Write "
โ JSON Parsing Failed
"
Response.Write "Error: " & json.LastError & "
"
If parsedData Is Nothing Then
Response.Write "Parse Result: Nothing object
"
Else
Response.Write "Parse Result: Object created
"
End If
Response.Write "JSON Preview: " & Left(jsonContent, 100) & "..."
Response.Write ""
End If
Else
testResults("fileLoad") = False
Response.Write "
"
Response.Write "
โ File Loading Failed
"
Response.Write "File: " & demoSampleFile & "
"
Response.Write "Error: " & Err.Description
Response.Write ""
End If
On Error Goto 0
Set fso = Nothing
%>
<% If testResults("fileLoad") Then %>
๐ Quick Data Preview
Company: <%= json.GetValue("company.name", "N/A") %>
Employees: <%= FormatNumber(json.GetValue("company.employees", 0), 0) %>
Founded: <%= json.GetValue("company.founded", 0) %>
Location: <%= json.GetValue("company.headquarters.city", "N/A") %>, <%= json.GetValue("company.headquarters.country", "N/A") %>
<% Else %>
โ ๏ธ Data Preview Unavailable
Parse Status: <%
If testResults.Exists("fileLoad") And testResults("fileLoad") Then
Response.Write "Success"
Else
Response.Write "Failed"
End If
%>
Last Error: <%= json.LastError %>
<% If testResults("fileLoad") Then %>
Debug Info: File loaded and parsed but data access failing
<% End If %>
<% End If %>
๐ HTTP URL Loading Demonstration
๐ Test 1: JSONPlaceholder API
<%
Dim http1StartTime, http1EndTime, json1, parsed1
http1StartTime = Timer
Set json1 = CreateRabbitJSON()
Set parsed1 = json1.Parse(demoApiUrl1)
http1EndTime = Timer
If Not (parsed1 Is Nothing) Then
testResults("api1Load") = True
testResults("api1Time") = (http1EndTime - http1StartTime) * 1000
Set json1.Data = parsed1
Response.Write "
"
Response.Write "
โ
SUCCESS - JSONPlaceholder API
"
Response.Write "URL: " & demoApiUrl1 & "
"
Response.Write "Response Time: " & FormatNumber(testResults("api1Time"), 2) & "ms
"
Response.Write "Data Keys: " & UBound(json1.GetKeys()) + 1 & ""
Response.Write ""
Response.Write "
"
Response.Write "Field | Value |
"
Response.Write "Post ID | " & json1.GetValue("id", "N/A") & " |
"
Response.Write "User ID | " & json1.GetValue("userId", "N/A") & " |
"
Response.Write "Title | " & Left(json1.GetValue("title", "N/A"), 60) & "... |
"
Response.Write "Body Length | " & Len(json1.GetValue("body", "")) & " chars |
"
Response.Write "
"
Else
testResults("api1Load") = False
Response.Write "
"
Response.Write "
โ FAILED - JSONPlaceholder API
"
Response.Write "Error: " & json1.LastError
Response.Write ""
End If
%>
๐ Test 2: GitHub API
<%
Dim http2StartTime, http2EndTime, json2, parsed2
http2StartTime = Timer
Set json2 = CreateRabbitJSON()
Set parsed2 = json2.Parse(demoApiUrl2)
http2EndTime = Timer
If Not (parsed2 Is Nothing) Then
testResults("api2Load") = True
testResults("api2Time") = (http2EndTime - http2StartTime) * 1000
Set json2.Data = parsed2
Response.Write "
"
Response.Write "
โ
SUCCESS - GitHub API
"
Response.Write "URL: " & demoApiUrl2 & "
"
Response.Write "Response Time: " & FormatNumber(testResults("api2Time"), 2) & "ms
"
Response.Write "Data Keys: " & UBound(json2.GetKeys()) + 1 & ""
Response.Write ""
Response.Write "
"
Response.Write "Field | Value |
"
Response.Write "Username | " & json2.GetValue("login", "N/A") & " |
"
Response.Write "Name | " & json2.GetValue("name", "N/A") & " |
"
Response.Write "Public Repos | " & FormatNumber(json2.GetValue("public_repos", 0), 0) & " |
"
Response.Write "Followers | " & FormatNumber(json2.GetValue("followers", 0), 0) & " |
"
Response.Write "Following | " & FormatNumber(json2.GetValue("following", 0), 0) & " |
"
Response.Write "
"
Else
testResults("api2Load") = False
Response.Write "
"
Response.Write "
โ FAILED - GitHub API
"
Response.Write "Error: " & json2.LastError
Response.Write ""
End If
%>
๐ Test 3: Backward Compatibility (JSON String)
<%
Dim compatStartTime, compatEndTime, json3, parsed3
compatStartTime = Timer
Dim compatJsonStr
compatJsonStr = "{""test"":""RabbitJSON v2.1.1"",""features"":[""file-loading"",""http-loading"",""path-access""],""version"":2.11,""ready"":true}"
Set json3 = CreateRabbitJSON()
Set parsed3 = json3.Parse(compatJsonStr)
compatEndTime = Timer
If Not (parsed3 Is Nothing) Then
testResults("compatLoad") = True
testResults("compatTime") = (compatEndTime - compatStartTime) * 1000
Set json3.Data = parsed3
Response.Write "
"
Response.Write "
โ
SUCCESS - Backward Compatibility
"
Response.Write "Input: Direct JSON String
"
Response.Write "Parse Time: " & FormatNumber(testResults("compatTime"), 2) & "ms
"
Response.Write "Features: URL detection did not interfere with JSON parsing"
Response.Write ""
Else
testResults("compatLoad") = False
Response.Write "
"
Response.Write "
โ FAILED - Backward Compatibility
"
Response.Write "Error: " & json3.LastError
Response.Write ""
End If
%>
<% If testResults("fileLoad") Then %>
๐ Comprehensive Data Analysis
๐ข Company Information
<%= json.GetValue("company.name", "N/A") %>
Company
<%= FormatNumber(json.GetValue("company.employees", 0), 0) %>
Employees
<%= json.GetValue("company.founded", 0) %>
Founded
<%= json.GetValue("company.headquarters.city", "N/A") %>
Headquarters
๐ฆ Products Portfolio
Product |
Category |
Price |
Downloads |
Rating |
Open Source |
<%
For i = 0 To 1
Response.Write ""
Response.Write "" & json.GetValue("products." & i & ".name", "N/A") & " | "
Response.Write "" & json.GetValue("products." & i & ".category", "N/A") & " | "
Response.Write "$" & json.GetValue("products." & i & ".price", 0) & " | "
Response.Write "" & FormatNumber(json.GetValue("products." & i & ".downloads.total", 0), 0) & " | "
Response.Write "" & json.GetValue("products." & i & ".ratings.average", 0) & "/5 | "
Response.Write "" & json.GetValue("products." & i & ".isOpenSource", False) & " | "
Response.Write "
"
Next
%>
๐ Analytics Dashboard
<%= FormatNumber(json.GetValue("analytics.traffic.dailyVisitors", 0), 0) %>
Daily Visitors
<%= FormatNumber(json.GetValue("analytics.traffic.monthlyVisitors", 0), 0) %>
Monthly Visitors
<%= FormatNumber(json.GetValue("analytics.traffic.pageViews", 0), 0) %>
Page Views
<%= FormatNumber(json.GetValue("analytics.traffic.bounceRate", 0) * 100, 1) %>%
Bounce Rate
๐ Geographic Distribution
Country |
Percentage |
Visitors |
<%
For i = 0 To 4
Response.Write ""
Response.Write "" & json.GetValue("analytics.geographical.topCountries." & i & ".country", "N/A") & " | "
Response.Write "" & json.GetValue("analytics.geographical.topCountries." & i & ".percentage", 0) & "% | "
Response.Write "" & FormatNumber(json.GetValue("analytics.geographical.topCountries." & i & ".visitors", 0), 0) & " | "
Response.Write "
"
Next
%>
๐ฅ๏ธ System Information
Component |
Value |
Operating System | <%= json.GetValue("systemInfo.server.os", "N/A") %> |
IIS Version | <%= json.GetValue("systemInfo.server.iisVersion", "N/A") %> |
ASP Version | <%= json.GetValue("systemInfo.server.aspVersion", "N/A") %> |
VBScript Version | <%= json.GetValue("systemInfo.server.vbscriptVersion", "N/A") %> |
CPU Model | <%= json.GetValue("systemInfo.server.cpu.model", "N/A") %> |
CPU Cores | <%= json.GetValue("systemInfo.server.cpu.cores", 0) %> |
Total Memory | <%= json.GetValue("systemInfo.server.memory.total", "N/A") %> |
Available Memory | <%= json.GetValue("systemInfo.server.memory.available", "N/A") %> |
๐งช Special Data Types Testing
Unicode: <%= json.GetValue("testData.specialCharacters", "N/A") %>
Emojis: <%= json.GetValue("testData.unicodeEmojis", "N/A") %>
Large Number: <%= json.GetValue("testData.numbers.large", 0) %>
Scientific: <%= json.GetValue("testData.numbers.scientific", 0) %>
Boolean True: <%= json.GetValue("testData.booleans.trueValue", False) %>
Boolean False: <%= json.GetValue("testData.booleans.falseValue", True) %>
<%
Dim nullValue
nullValue = json.GetValue("testData.nullValue", "NOT_NULL")
If IsNull(nullValue) Then
Response.Write "
Null Value: null (correctly parsed)
"
Else
Response.Write "
Null Value: Error - not null!
"
End If
%>
<% Else %>
โ ๏ธ Data Analysis Unavailable
Please ensure the file loading was successful to view data analysis.
<% End If %>
<%
endTime = Timer
totalTime = (endTime - startTime) * 1000
%>
โก Performance Analysis & Benchmarks
<%= FormatNumber(totalTime, 2) %>ms
Total Demo Time
<% If testResults.Exists("fileLoadTime") Then %>
<%= FormatNumber(testResults("fileLoadTime"), 2) %>ms
File Load Time
<% End If %>
<% If testResults.Exists("api1Time") Then %>
<%= FormatNumber(testResults("api1Time"), 2) %>ms
API 1 Response
<% End If %>
<% If testResults.Exists("api2Time") Then %>
<%= FormatNumber(testResults("api2Time"), 2) %>ms
API 2 Response
<% End If %>
๐ Detailed Performance Metrics
Operation |
Time (ms) |
Status |
Details |
<% If testResults.Exists("fileLoadTime") Then %>
File Loading |
<%= FormatNumber(testResults("fileLoadTime"), 2) %> |
<%= IIf(testResults("fileLoad"), "โ
Success", "โ Failed") %> |
<%= FormatNumber(testResults("fileSize"), 0) %> characters |
File Parsing |
<%= FormatNumber(testResults("fileParseTime"), 2) %> |
<%= IIf(testResults("fileLoad"), "โ
Success", "โ Failed") %> |
JSON structure analysis |
<% End If %>
<% If testResults.Exists("api1Time") Then %>
HTTP API 1 |
<%= FormatNumber(testResults("api1Time"), 2) %> |
<%= IIf(testResults("api1Load"), "โ
Success", "โ Failed") %> |
JSONPlaceholder API |
<% End If %>
<% If testResults.Exists("api2Time") Then %>
HTTP API 2 |
<%= FormatNumber(testResults("api2Time"), 2) %> |
<%= IIf(testResults("api2Load"), "โ
Success", "โ Failed") %> |
GitHub API |
<% End If %>
<% If testResults.Exists("compatTime") Then %>
JSON String Parse |
<%= FormatNumber(testResults("compatTime"), 2) %> |
<%= IIf(testResults("compatLoad"), "โ
Success", "โ Failed") %> |
Backward compatibility |
<% End If %>
๐ป Usage Code Examples
RabbitJSON v2.1.1 Usage Examples:
' File Loading Example
Set json = CreateRabbitJSON()
Set data = json.Parse("sample-data.json") ' File path
companyName = json.GetValue("company.name", "")
' HTTP URL Loading Example
Set apiData = json.Parse("https://api.github.com/users/octocat") ' HTTP URL
username = json.GetValue("login", "")
' Regular JSON String (Backward Compatible)
Set localData = json.Parse("{""key"":""value""}") ' JSON string
value = json.GetValue("key", "")
' Path-based Data Access
employeeCount = json.GetValue("company.employees", 0)
latitude = json.GetValue("company.headquarters.address.coordinates.latitude", 0)
firstProductName = json.GetValue("products.0.name", "")
' Data Manipulation
json.SetValue "demo.timestamp", Now()
json.SetValue "demo.processed", True
hasValue = json.HasValue("analytics.traffic")
' Serialization
compactJson = json.StringifyCompact(json.Data)
formattedJson = json.Stringify(json.Data, 2)
<%
' Cleanup
Set json = Nothing
Set json1 = Nothing
Set json2 = Nothing
Set json3 = Nothing
Set parsedData = Nothing
Set parsed1 = Nothing
Set parsed2 = Nothing
Set parsed3 = Nothing
Set testResults = Nothing
%>