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 6602937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:56:23+00:00 2026-05-25T18:56:23+00:00

I have some JSON data that looks like this: { data: [{ name:John Smith,

  • 0

I have some JSON data that looks like this:

{
    "data":
    [{
        "name":"John Smith",
        "id":"12345"
    }]
}

I have a pair of serializeable classes like so:

<Serializable()> _
Public Class User
    Private _name As String
    Private _id As String

    Public Property name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property

    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal value As String)
            _id = value
        End Set
    End Property
End Class

<Serializable()>
Public Class UserData
    Private _data As List(Of User)

    Public Property data() As List(Of User)
        Get
            Return (_data)
        End Get

        Set(ByVal value As List(Of User))
            _data = value
        End Set
    End Property

End Class

When I try to deserialize as an object:

Dim serializer As New JavaScriptSerializer()
Dim userResult As Object = serializer.DeserializeObject(json)

I get one root object with key “data”, and value another object with 2 children, with keys “name” and “id”, and the appropriate values one might expect. But when I try to cast that object to my UserData type, it returns Nothing. I had this code working at some point, but now that I am returning to it and attempting to use it again, it seems some code rot has set in and it has stopped working.

Here is how I am attempting to get the deserialized data as a UserData object:

Dim userResult As UserData = TryCast(serializer.DeserializeObject(json), UserData)
  • 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-05-25T18:56:23+00:00Added an answer on May 25, 2026 at 6:56 pm

    I was able to fix this issue by changing

    Dim userResult As UserData = TryCast(serializer.DeserializeObject(json), UserData)
    

    to

    Dim userResult As UserData = serializer.Deserialize(Of UserData)(json)
    

    Not exactly sure what the functional difference here is, but that got me the result i wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object in Javascript that looks like this function MyObject(){ this.name=; this.id=0;
Here's an interesting problem: I have some jQuery that looks like this: $(document).ready(function() {
I have some JSON which looks generally like this... {appJSON: [ { title:Application Title,
I have some classes layed out like this class A { public virtual void
I'm trying to generate a JSON response that includes some HTML. Thus, I have
I have some UI in VB 2005 that looks great in XP Style, but
We have some input data that sometimes appears with &nbsp characters on the end.
I have some code like this in a winforms app I was writing to
I have some kind of test data and want to create a unit test
We have some files on our website that users of our software can download.

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.