Need help with JSON 07-18-2013, 07:25 PM
#1
I need help with JSON because i want to deserialize the values given from BTC Guild so i can make a client with shows statistic better than the site itself.
So please if someone could help me with the code it would be great.
(I just copied my old JSON code from my price checker in hope that it would work, but it didn't.)
I really have no idea how to parse it.
So please if someone could help me with the code it would be great.
(I just copied my old JSON code from my price checker in hope that it would work, but it didn't.)
I really have no idea how to parse it.
Spoiler:
Quote:Imports System.Web.Script.Serialization
Imports System.Reflection
Imports System.Net
Public Class Form1
Dim jss As New JavaScriptSerializer()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim li1 As New ListViewItem
Dim TempUrl As String
TempUrl = "https://www.btcguild.com/api.php?api_key=cae2824447c34d9bc071251febc86b93"
Try
Dim ResultJSON As String = New WebClient().DownloadString(TempUrl)
Dim Ritem As RuneItem = jss.Deserialize(Of List(Of RuneItem))(ResultJSON)(0)
lstv_Reader.Items.Clear()
For Each ROffer As RuneOffer In Ritem.Offers
li1.SubItems.Add(ROffer.user_id)
Next
Catch ex As Exception
MsgBox("Something went wrong!")
End Try
End Sub
End Class
Public Class RuneItem
Public Property user_id As Integer
Public Property total_rewards As Integer
Public Property paid_rewards As Integer
Public Property unpaid_rewards As String
Public Property past_24h_rewards As String
Public Property total_rewards_nmc As String
Public Property paid_rewards_nmc As String
Public Property unpaid_rewards_nmc As Integer
Public Property past_24h_rewards_nmc As Integer
Public Property workers As Integer
Public Property worker_name As String
Public Property hash_rate As String
Public Property valid_shares As String
Public Property stale_shares As String
Public Property dupe_shares As Integer '
Public Property unknown_shares As String
Public Property valid_shares_since_reset As String
Public Property dupe_shares_since_reset As String
Public Property unknown_shares_since_reset As String
Public Property stale_shares_nmc As Integer '
Public Property pool_speed As String
Public Property pps_rate As String
Public Property difficulty As String
Public Property pps_rate_nmc As String
Public Property difficulty_nmc As String
Public Property Offers As RuneOffer()
End Class
Public Class RuneOffer
Public Property user_id As Integer
Public Property total_rewards As Integer
Public Property paid_rewards As Integer
Public Property unpaid_rewards As String
Public Property past_24h_rewards As String
Public Property total_rewards_nmc As String
Public Property paid_rewards_nmc As String
Public Property unpaid_rewards_nmc As Integer
Public Property past_24h_rewards_nmc As Integer
Public Property workers As Integer
Public Property worker_name As String
Public Property hash_rate As String
Public Property valid_shares As String
Public Property stale_shares As String
Public Property dupe_shares As Integer '
Public Property unknown_shares As String
Public Property valid_shares_since_reset As String
Public Property dupe_shares_since_reset As String
Public Property unknown_shares_since_reset As String
Public Property stale_shares_nmc As Integer '
Public Property pool_speed As String
Public Property pps_rate As String
Public Property difficulty As String
Public Property pps_rate_nmc As String
Public Property difficulty_nmc As String
End Class
![[Image: tumblr_m4vms28lYu1qj3ir1.gif]](http://media.tumblr.com/tumblr_m4vms28lYu1qj3ir1.gif)