ASPJSON is a free to use project for generating and reading JSON data into a classic ASP object.
The class can be used for reading a string of JSON data as well as writing JSON output from an AJAX file.
Below are 2 simple examples of both.
Please feel free to give feedback or report a bug in the github project
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!--#include virtual="/aspJSON1.18.asp" --> <% Set oJSON = New aspJSON 'Load JSON string oJSON.loadJSON(jsonstring) 'Get single value Response.Write oJSON.data("firstName") & "<br>" 'Loop through collection For Each phonenr In oJSON.data("phoneNumbers") Set this = oJSON.data("phoneNumbers").item(phonenr) Response.Write _ this.item("type") & ": " & _ this.item("number") & "<br>" Next 'Update/Add value oJSON.data("firstName") = "James" 'Return json string Response.Write oJSON.JSONoutput() %>
[INPUT]{ "firstName": "John", "lastName" : "Smith", "age" : 25, "address" : { "streetAddress": "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : "10021" }, "phoneNumbers": [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }
Release 1.18 August 2020
- Decimal output comma/dot fix
Release 1.17 Februari 2014
- Efficiency improvement large data
Release 1.15 Februari 2014
- Trailing tabs fixed
Release 1.14 Februari 2014
- Colon value within string bug fixed
Release 1.13 December 2013
- Encoded data fix
- Now possible to load directly from a URL.
For example: oJSON.loadJSON("http://www.aspjson.com/jsonstream.asp")
Release 1.12 June 2013
- vbCrLf fix
- Compatible with Option Explicit
- JSON escape characters