ASP的JSON类使用方法


ASP #json #2012-05-11 09:18

前面我们介绍了ASP的JSON类 http://yige.org/p/188 ,现在我们来举例,学会用JSON类。

Hello World!
示例:
<!--#include file="JSON_latest.asp"-->
<%
Dim member
Set member = jsObject()


member("name") = "Tuğrul"
member("surname") = "Topuz"
member("message") = "Hello World"


member.Flush
%>
输出:
{"name":"Tu\u011Frul","surname":"Topuz","message":"Hello World"}
SQL Queries
示例:
<!--#include file="JSON_latest.asp"-->
<!--#include file="JSON_UTIL_latest.asp"-->
<%
QueryToJSON(dbconn, "SELECT name, surname FROM members WHERE age < 30").Flush
%>
输出:
[
    {
        "name":"ali",
        "surname":"osman"
    },
    {
        "name":"mahmut",
        "surname":"\u00E7\u0131nar"
    }
]
Multi Dimensional Arrays
示例:
<!--#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)
%>
输出:
[["zero - zero","zero - one"],["one - zero","one - one"]]


相关文章

粤ICP备11097351号-1