http://tforster.wik.is/ASP_Classic_Practices_For_The_21st_Century/JSON4ASP
sample
<!--#include file="JSON_latest.asp"-->
<%
Dim member
Set member = jsObject()
member("name") = "Tuğrul"
member("surname") = "Topuz"
member("message") = "Hello World"
member.Flush
%>
output
{"name":"Tu\u011Frul","surname":"Topuz","message":"Hello World"}
SQL Queries
sample
<!--#include file="JSON_latest.asp"-->
<!--#include file="JSON_UTIL_latest.asp"-->
<%
QueryToJSON(dbconn, "SELECT name, surname FROM members WHERE age < 30").Flush
%>
output
[
{
"name":"ali",
"surname":"osman"
},
{
"name":"mahmut",
"surname":"\u00E7\u0131nar"
}
]
Multi Dimensional Arrays
sample
<!--#include file="JSON_latest.asp"-->
<%
Dim a(1,1)
a(0,0) = "zero - zero"
a(0,1) = "zero - one"
a(1,0) = "one - zero"
a(1,1) = "one - one"
Response.Write toJSON(a)
%>
output
[["zero - zero","zero - one"],["one - zero","one - one"]]
<script language="javascript" runat="server" src="json2.min.asp"></script> <script language="vbscript" runat="server"> Option Explicit Dim car: Set car = JSON.parse("{""brand"":""subaru"",""model"":""outback sport"",""year"":2003," & _ """colour"":""green"",""accessories"":[" & _ "{""foglamps"":true},{""abs"":true},{""heatedSeats"":true}]}") Response.Write("brand: " & car.brand & "<br/>") Response.Write("model: " & car.model & "<br/>") Response.Write("colour: " & car.colour & "<br/>") Response.Write("has foglamps: " & CStr(car.accessories.get(0).foglamps) & "<br/>") car.accessories.get(0).foglamps = false Response.Write("has foglamps: " & CStr(car.accessories.get(0).foglamps) & "<br/>") Response.Write("new Json: " & JSON.stringify(car) & "<br/>") Set car = Nothing </script>
'asp' 카테고리의 다른 글
ASP 페이징 객체지향 흉내내서 구현하기 (0) | 2010.09.27 |
---|---|
정규식을 이용한 태그 제거 함수 (0) | 2010.09.27 |
ADO CreateParameter Method (0) | 2010.08.24 |
ADO 사용하여 Access 데이터베이스에 매개 변수가 있는 쿼리 호출 방법 (0) | 2010.08.24 |
닷넷으로 작성해서 classic asp에서 사용하기. (0) | 2010.08.24 |