ASPjson

Read and write json data in and from Classic ASP
From http://www.aspjson.com/


Public

Not Tested

Not My Work
Usage - Reading json:
<!--#include virtual="/aspJSON1.17.asp" -->
<%
Set oJSON = New aspJSON
'Load JSON string
oJSON.loadJSON(jsonstring)
'Get single value
Response.Write oJSON.data("firstName") & "
"
'Loop through collection
For Each phonenr In oJSON.data("phoneNumber")
Set this = oJSON.data("phoneNumber").item(phonenr)
Response.Write _
this.item("type") & ": " & _
this.item("number") & "
"
Next
'Update/Add value
oJSON.data("firstName") = "James"
'Return json string
Response.Write oJSON.JSONoutput()
%>

Usage - Writing json:
<!--#include virtual="/aspJSON1.17.asp" -->
<%
Set oJSON = New aspJSON
With oJSON.data
.Add "familyName", "Smith" 'Create value
.Add "familyMembers", oJSON.Collection()
With oJSON.data("familyMembers")
.Add 0, oJSON.Collection() 'Create object
With .item(0)
.Add "firstName", "John"
.Add "age", 41
End With
.Add 1, oJSON.Collection()
With .item(1)
.Add "firstName", "Suzan"
.Add "age", 38
.Add "interests", oJSON.Collection() 'Create array
With .item("interests")
.Add 0, "Reading"
.Add 1, "Tennis"
.Add 2, "Painting"
End With
End With
.Add 2, oJSON.Collection()
With .item(2)
.Add "firstName", "John Jr."
.Add "age", 2.5
End With
End With
End With
Response.Write oJSON.JSONoutput() 'Return json string
%>

Views 86 Downloads 27

Classic ASP File System
ANmarAmdeen
695
Attachments
Revisions

v1.0