http://code.google.com/p/aspjson/

5 篇文章 0 订阅

Featured
Downloads
Wiki pages


aspjson is JSON serializer for VBScript based ASP server technology.

It uses VBScript's primitive types except Object and Array types. jsObject and jsArray classes stand JSON Object and Array dynamically on server side. These classes derive core functionality from jsCore.

aspjson supports nested types for block of buildings, such as jsObject instances can contain Numbers, Strings, Nulls, Arrays and other primitive types, jsArray instances can contain these jsObject instances or all of the primitive types.

Hello World!

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"]]
Asp 这个老古懂估计没几个人在用了。几年没写代码了,最近要弄个小东西,给手机端提供json数据,不想麻烦别人,自己又只会asp,没办法就自己动手了。网上找了好久都没有一个人能完整的把asp操作json说清楚。最后还是自己搞定的。整出来共享给大家。(ps,还有个原因csdn的分不够用啦,大家看着给点吧。写这个说明文档都用了我两小时。^_^) 以下是示例代码 '说明:json.asp中引用了json.js.asp '其他见文档 '手机很多时候不认gb2312,跳入json的坑就忘记gb2312吧,讨厌的是,如果代码报错,iis会输出gb2312,结果就是乱码,有点烦。 '自己想办法解决吧 response.Charset= "utf-8" dim strJsonData,ovbJson,j dim arrTemp,varname ,i set ovbJson=new vbJson 'asp recrodset和数组转json字符 arrTemp=array("a","{""oa"":""我是oa""}","c") strJsonData=ovbjson.toJson(empty,arrTemp,true) '转换为Json格式的字符串,有兴趣可以自己输出看看是什么 set j=json.parse(strJsonData) '序列化为json对象(或者是数组对象) response.Write(j.get(1)&"") '别用vb数组来存json对象,不然得每个元素去重新序列化,这里如果想j.get(1).oa就不行了。必须对j.get(1)单独序列才行 '----recrodset就不演示了,懒得连数据库 '---自定义操作方法的演示--- strJsonData="{a:1,b:[{c:'我是数组中的点c'}]}" set j=json.parsestr(strJsonData) response.Write(j.b.get(0).c&"") '添加节点的时候注意,如果值是null,会被忽然,这个节点会不存在的。在添加之前记得先检查值 set j=json.add(j,"new","我是新加的节点") response.Write(j.new&"") '下面这句注掉了,是因为这个操作是无效的因为j.b是数组,不能add 'set j=json.add(j.b,"new1","我是加不进的节点") set j.b=j.b.put(j.b.length,j.b.get(0)) response.Write(j.b.get(1).c&",我是新加的数组元素") '因为数组的get方法不允许被赋值,所以不能像下面这样写 'set j.b.get(0)=json.add(j.b.get(0),"new","我会报错") json.add j.b.get(0),"new","我是新加的new我不会报错" json.add j.b.get(0),"new1","我是通过变量取出来的哦" response.Write(j.b.get(0).new&"") varname="new1" response.Write(json.byname(j.b.get(0),varname)&"") for i=0 to j.b.length-1 varname="c" response.Write(json.byname(j.b.get(i),varname)&"我是循环出来的c,索引:"&i&" ") next '最后完整的输出给手机就这样: response.Write json.stringify(j)
要使用token验证身份,你可以按照以下步骤进行操作: 1. 首先,你需要通过OAuth2授权流程获取到一个授权码(code)。你可以使用以下链接进行授权: \[https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://localhost&client_id=client_id\](https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://localhost&client_id=client_id) \[1\] 2. 使用获取到的授权码(code),通过POST请求获取到一个刷新令牌(refresh_token)。你可以使用以下链接进行POST请求: \[https://accounts.google.com/o/oauth2/token?grant_type=authorization_code&code=浏览器地址栏的code&client_id=OAuth的id编号&client_secret=OAuth的密钥(id编号下面那个)&redirect_uri=http://localhost(刚刚新增的URL)\](https://accounts.google.com/o/oauth2/token?grant_type=authorization_code&code=浏览器地址栏的code&client_id=OAuth的id编号&client_secret=OAuth的密钥(id编号下面那个)&redirect_uri=http://localhost(刚刚新增的URL)) \[2\] 3. 最后,你可以使用获取到的刷新令牌(refresh_token)来进行身份验证。你可以使用以下链接进行身份验证: \[https://accounts.google.com/o/oauth2/v2/auth?scope=https://mail.google.com/&access_type=offline&redirect_uri=http://localhost&response_type=code&client_id=\[your_client_id\]\](https://accounts.google.com/o/oauth2/v2/auth?scope=https://mail.google.com/&access_type=offline&redirect_uri=http://localhost&response_type=code&client_id=\[your_client_id\]) \[3\] 请注意,上述链接中的一些参数需要你根据实际情况进行替换,比如client_id和code等。另外,这些链接是示例链接,你需要根据你的具体需求进行相应的修改。 #### 引用[.reference_title] - *1* *2* [谷歌支付获取refresh token](https://blog.csdn.net/wuyadafeiji/article/details/127886603)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Google Gmail Oauth Client ID 认证指南](https://blog.csdn.net/hantangduhey/article/details/126704183)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值