首页 > 解决方案 > 如何正确解析这个 JSON 字符串

问题描述

我有一些返回以下 JASON 的 API,我试图解析它以便能够从我想要的任何属性中提取。

JSON 我试图解析:https ://pastebin.com/i06GRD0f

我假设正确的方法是将所有内容加载到数组中,但我无法让它正常工作,因为它与所有不同的参数有点混淆。

Imports System.Web.Script.Serialization


Public Class ServerAttributes
    Public Property assists() As String
    Public Property bestRankPoint() As String
    Public Property boosts() As String
    Public Property dBNOs() As String
    Public Property dailyKills() As String
    Public Property dailyWins() As String

    Public Property damageDealt() As String
    Public Property days() As String
    Public Property headshotKills() As String
    Public Property heals() As String
    Public Property killPoints() As String
    Public Property kills() As String

    Public Property longestKill() As String
    Public Property longestTimeSurvived() As String
    Public Property losses() As String
    Public Property maxKillStreaks() As String
    Public Property mostSurvivalTime() As String
    Public Property rankPoints() As String

    Public Property rankPointsTitle() As String
    Public Property revives() As String
    Public Property rideDistance() As String
    Public Property roadKills() As String
    Public Property roundMostKills() As String
    Public Property roundsPlayed() As String

    Public Property suicides() As String
    Public Property swimDistance() As String
    Public Property teamKills() As String
    Public Property timeSurvived() As String
    Public Property top10s() As String
    Public Property vehicleDestroys() As String

    Public Property walkDistance() As String
    Public Property weaponsAcquired() As String
    Public Property weeklyKills() As String
    Public Property weeklyWins() As String
    Public Property winPoints() As String
    Public Property wins() As String
End Class

Public Class ServerData
    Public Property data() As ServerAttributes
End Class

Module StaterMainClass
    Public Sub GetInfo()
        Dim jss As New JavaScriptSerializer()
        Dim DataResponse As ServerData = jss.Deserialize(Of ServerData)(JSON)

        Debug.Print(DataResponse.data.assists(0))
   End Sub

End Module

标签: vb.net

解决方案


推荐阅读