Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9270615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:24:53+00:00 2026-06-18T15:24:53+00:00

Trying to deserialise the following json returned from a web source: { cards: [

  • 0

Trying to deserialise the following json returned from a web source:

{
    "cards": [
    {
        "high": "8.27", 
        "volume": 5, 
        "percent_change": "0.00", 
        "name": "Wurmcoil engine", 
        "url": "http://blacklotusproject.com/cards/Scars+of+Mirrodin/Wurmcoil+Engine/", 
        "price": "6.81", 
        "set_code": "SOM", 
        "average": "5.67", 
        "change": "0.00", 
        "low": "1.12"}], 
        "currency": "USD"
    }

I am using json.net with visual basic, new to both of them, especially the object oriented portions of vb. I would just like to extract the ‘price’ variable.
I have set up a class as such:

Public Class Card
    Public high As String
    Public volume As String
    Public percent_change As String
    Public name As String
    Public url As String
    Public price As String
    Public set_code As String
    Public average As String
    Public change As String
    Public low As String
End Class

The code I am currently using is:

Public Sub parse_json(url As String)
    Dim blp_json As String = ""
    Dim wClient As New WebClient
    wClient.Proxy = System.Net.HttpWebRequest.DefaultWebProxy
    blp_json = wClient.DownloadString(url)
    MessageBox.Show(blp_json)
    Dim card_1 = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Card)(blp_json)
    PriceTextBox.Text = card_1.price
    TextBox1.AppendText(card_1.ToString)
    TextBox1.AppendText(blp_json)

End Sub

Just trying many different things to get a hang of it, not really sure what I am doing. I presume my Card class is incorrect as ‘price’ appears to be nested in cards:[{…}]

I don’t really know about deserialising json at all, and much less about how to do it /properly/ in vb.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:24:54+00:00Added an answer on June 18, 2026 at 3:24 pm

    I use the System.Web.Script.Serialization.JavaScriptSerializer for JSON deserialization. Your example is slightly complicated by the fact that cards contains an array of JSON objects. This is indicated by the “[” and “]”. This example code will show you how to process it regardless of whether cards is an array or not. You may wish to ignore the Else if you are sure that there will always be an array in cards

    Make sure that you have included a reference to System.Web.Extensions in your project and…

    Imports System.Web.Script.Serialization
    

    and then…

    Dim MySerializer As JavaScriptSerializer = New JavaScriptSerializer()
    Dim dictResult As Dictionary(Of String, Object) = MySerializer.Deserialize(Of Dictionary(Of String, Object))(blp_json)
    
    Dim dictCard As Dictionary(Of String, Object)
    
    If dictResult.ContainsKey("cards") Then
    
        If TypeOf dictResult("cards") Is ArrayList Then
    
            Dim arrResult As ArrayList = DirectCast(dictResult("cards"), ArrayList)
    
            For Each arrCardRecord In arrResult
    
                dictCard = DirectCast(arrCardRecord, Dictionary(Of String, Object))
    
                If dictCard.ContainsKey("price") Then Console.WriteLine(dictCard("price"))
    
            Next
        Else
            dictCard = DirectCast(dictResult("cards"), Dictionary(Of String, Object))
            If dictCard.ContainsKey("price") Then Console.WriteLine(dictCard("price"))
        End If
    
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON: {workspace: { name:Dallas, dataStores:http://.....:8080/geoserver/rest/workspaces/Dallas/datastores.json, coverageStores:http://.....:8080/geoserver/rest/workspaces/Dallas/coveragestores.json, wmsStores:http://....:8080/geoserver/rest/workspaces/Dallas/wmsstores.json}} And I´m trying
UPDATED: I have the following code, where I am trying to use returned JSON
I'm trying to deserialize the following json: { books: [ {id:1,name:book 1}, {id:2,name:book 2}
I'm using JSON.NET to deserialize some JSON returned from a web service. Unfortunately, i'm
I'm trying to deserialize json data services recieved from a web server into an
I am trying to deserialize this JSON array into my android project. [{Name:Ban,Price:1},{Name:Banana,Price:1},{Name:chicken,Price:14},{Name:pizza,Price:16},{Name:slice,Price:1}] I
I've got the following XML i'm trying to deserialise with XmlSerialiser: <playlist> <id>43712</id> <title>Eleven
I am trying to parse out data from oodle.com api feed using the JSON.NET
I am trying to deserialize the json string in C#. Following is jsonstring and
I am trying to deserialize the following JSON, but I really have no idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.