һַ
<%
Dim jsonStr, json
jsonStr = GetFile("json.txt")
Set json = parseJSON(jsonStr)
Response.Write "status: " & json.status & "
"
Response.Write "city_name: " & json.weather.get(0).city_name & "
" & VbCrLf
Dim future, C, I
Set future = json.weather.get(0).future
C = future.length - 1
Response.Write "
"Response.Write "
date | high | low | day | text | code1 | code2 | cop | wind |
"For I = 0 To C
Response.Write "
" & future.Get(I).date & " | " & VbCrLf & _ "
" & future.Get(I).high & " | " & VbCrLf & _ "
" & future.Get(I).low & " | " & VbCrLf & _ "
" & future.Get(I).day & " | " & VbCrLf & _ "
" & future.Get(I).text & " | " & VbCrLf & _ "
" & future.Get(I).code1 & " | " & VbCrLf & _ "
" & future.Get(I).code2 & " | " & VbCrLf & _ "
" & future.Get(I).cop & " | " & VbCrLf & _ "
" & future.Get(I).wind & " | " & VbCrLf & _ "
"
Next
Response.Write "
"
'PR getjson(jsonStr)
Dim scriptCtrl
Function parseJSON(str)
If Not IsObject(scriptCtrl) Then
Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")
scriptCtrl.Language = "JScript"
scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"
End If
scriptCtrl.ExecuteStatement "result = " & str & ";"
Set parseJSON = scriptCtrl.CodeObject.result
End Function
Function GetFile(sFileName)
Dim oFso, oFout
Set oFso = Server.CreateObject("Scripting.FileSystemObject")
If oFso.FileExists(Server.Mappath(sFileName)) Then
Set oFout = oFso.OpenTextFile(Server.Mappath(sFileName), 1, False)
On Error Resume Next
GetFile = oFout.ReadAll()
If Err Then
Err.Clear
GetFile = ""
End If
oFout.Close
Set oFout = Nothing
Else
GetFile = ""
End If
Set oFso = Nothing
End Function
%>
ڶַ
<%
Dim jsonStr, json
jsonStr = GetFile("json.txt")
Set json = parseJSON(jsonStr)
Response.Write "status: " & json.status & "
"
Response.Write "city_name: " & json.weather.get(0).city_name & "
" & VbCrLf
Dim future, C, I
Set future = json.weather.get(0).future
C = future.length - 1
Response.Write "
"Response.Write "
date | high | low | day | text | code1 | code2 | cop | wind |
"For I = 0 To C
Response.Write "
" & future.Get(I).date & " | " & VbCrLf & _ "
" & future.Get(I).high & " | " & VbCrLf & _ "
" & future.Get(I).low & " | " & VbCrLf & _ "
" & future.Get(I).day & " | " & VbCrLf & _ "
" & future.Get(I).text & " | " & VbCrLf & _ "
" & future.Get(I).code1 & " | " & VbCrLf & _ "
" & future.Get(I).code2 & " | " & VbCrLf & _ "
" & future.Get(I).cop & " | " & VbCrLf & _ "
" & future.Get(I).wind & " | " & VbCrLf & _ "
"
Next
Response.Write "
"
'PR getjson(jsonStr)
Dim scriptCtrl
Function parseJSON(str)
If Not IsObject(scriptCtrl) Then
Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")
scriptCtrl.Language = "JScript"
scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"
End If
scriptCtrl.ExecuteStatement "result = " & str & ";"
Set parseJSON = scriptCtrl.CodeObject.result
End Function
Function GetFile(sFileName)
Dim oFso, oFout
Set oFso = Server.CreateObject("Scripting.FileSystemObject")
If oFso.FileExists(Server.Mappath(sFileName)) Then
Set oFout = oFso.OpenTextFile(Server.Mappath(sFileName), 1, False)
On Error Resume Next
GetFile = oFout.ReadAll()
If Err Then
Err.Clear
GetFile = ""
End If
oFout.Close
Set oFout = Nothing
Else
GetFile = ""
End If
Set oFso = Nothing
End Function
%>
2пԸݲͬв