使用JSON API [英] Working With JSON API
本文介绍了使用JSON API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Friend我正在研究JSON API,输出是这样的
Hello Friend I am working on a JSON API and the output is something like this
{
"players":
[
{
"name":"1ApRiL",
"rank":13,
"rank_name":"STAFF SERGEANT I",
"veteran":4,
"score":195385,
"level":164,
"kills":821,
"deaths":736,
"time":49090.766,
"elo":118.936,
"form":1,
"date_lastupdate":"2010-03-21T02:02:49+01:00",
"count_updates":17,
"general":{},
......
},
......
],
"requested":2,
"found":0
}
但是有人能告诉我如何管理每个标签中的每个值以及如何这样做?
But can anyone tell me how to manage each value in each label and how to do it?
推荐答案
你可以使用 jQuery $ c读取 json
$ c>并为此动态创建标签
。
参见演示 - [DEMO]使用JSON API [ ^ ]。
You ca read thejson
usingjQuery
and dynamically createlabels
for that.
See the DEMO - [DEMO] Working With JSON API[^].
谢谢你们,但我已修复它
Thanks you guys but I have fixed it
Imports System.Net
Imports System.IO
Module Module1
Sub Main()
Console.WriteLine("I love Qmz_")
Console.WriteLine("Press any key to start")
Console.ReadKey()
Console.WriteLine(vbNewLine)
Console.WriteLine("Checking... Please wait.")
Console.WriteLine(vbNewLine)
Dim url As String = "your api link here"
Dim json As String = String.Empty
Using client As New WebClient
Try
json = client.DownloadString(url)
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
End Using
json = json.Replace(vbLf.ToCharArray, "")
json = json.Replace(Chr(34), "")
Dim pos As Integer = InStr(json, "players")
json = json.Substring(pos - 1, Len(json) - pos)
pos = json.IndexOf("}")
json = json.Substring(0, pos)
Dim jsonArray() As String = json.Split(",".ToCharArray)
Dim temp() As String
For i As Integer = 0 To jsonArray.GetUpperBound(0)
temp = jsonArray(i).Split(":".ToCharArray)
If jsonArray(i).IndexOf("players") > -1 Then
Console.WriteLine("Players: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("name") > -1 Then
Console.WriteLine("name: " & temp(1).Trim())
ElseIf jsonArray(i).IndexOf("rank") > -1 Then
Console.WriteLine("rank: " & temp(1).Trim())
ElseIf jsonArray(i).IndexOf("rank_name") > -1 Then
Console.WriteLine("rank name: " & temp(1).Trim())
ElseIf jsonArray(i).IndexOf("veteran") > -1 Then
Console.WriteLine("veteran: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("score") > -1 Then
Console.WriteLine("score: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("level") > -1 Then
Console.WriteLine("level: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("kills") > -1 Then
Console.WriteLine("kills: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("deaths") > -1 Then
Console.WriteLine("deaths: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("time") > -1 Then
Console.WriteLine("time: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("elo") > -1 Then
Console.WriteLine("elo: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("form") > -1 Then
Console.WriteLine("form: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("date_lastupdate") > -1 Then
Console.WriteLine("last update date: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("count_update") > -1 Then
Console.WriteLine("count update: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("general") > -1 Then
Console.WriteLine("general: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("requested") > -1 Then
Console.WriteLine("requested: " & temp(1).Trim)
ElseIf jsonArray(i).IndexOf("found") > -1 Then
Console.WriteLine("found: " & temp(1).Trim)
End If
Erase temp
Next
Erase jsonArray
Console.WriteLine(vbNewLine)
Console.WriteLine("Done !")
Console.ReadKey()
End Sub
End Module
这篇关于使用JSON API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文