반응형
asp - JSON : http://www.aspjson.com/
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.
<!--#include virtual="/aspJSON1.17.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("phoneNumber") Set this = oJSON.data("phoneNumber").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" }, "phoneNumber": [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }
반응형