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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:18:24+00:00 2026-05-24T11:18:24+00:00

I finally got this to work using the javascriptserializer to deserialize the json content.

  • 0

I finally got this to work using the javascriptserializer to deserialize the json content. Now I have the objects in a dictionary and would like to access the contents to get the key values. I want to grab the values of certain fields only.

{
  "data": [
  {
     "id": "56381779049_10150352298839050",
     "from": {
        "name": "Paulina Soto",
        "id": "1619854594"
     },
     "to": {
        "data": [
           {
              "name": "Pepsi",
              "category": "Food/beverages",
              "id": "56381779049"
           }
        ]
     },
     "message": "La coca es mejor que la pepsi :D.",
     "type": "status",
     "created_time": "2011-08-11T20:43:18+0000",
     "updated_time": "2011-08-11T20:43:18+0000",
     "comments": {
        "count": 0
     }
  },
  {
     "id": "56381779049_10150352296084050",
     "from": {
        "name": "William Scott Jennings",
        "id": "1125852789"
     },
     "to": {
        "data": [
           {
              "name": "Pepsi",
              "category": "Food/beverages",
              "id": "56381779049"
           }
        ]
     },
     "message": "Don't buy the new Pepsi can coming out with pictures of the Empire State building and The Pledge of Allegiance on them. Pepsi left out two little words on the pledge, \"Under God.\" Pepsi said they didn't want to offend anyone. So if we don't buy them they won't be offended when they don't receive our money that has the words \"In God We Trust\" on it. How fast can you re post this? It is offensive to leave out Under God\r\nDon't buy the new Pepsi can coming out with pictures of the Empire State building and The Pledge of Allegiance on them. Pepsi left out two little words on the pledge, \"Under God.\" Pepsi said they didn't want to offend anyone. So if we don't buy them they won't be offended when they don't receive our money that has the words \"In God We Trust\" on it. How fast can you re post this? It is offensive to leave out Under God\r\n",
     "type": "status",
     "created_time": "2011-08-11T20:39:59+0000",
     "updated_time": "2011-08-11T20:39:59+0000",
     "comments": {
        "count": 0
     }
  },
  {
     "id": "56381779049_10150352295939050",
     "from": {
        "name": "William Scott Jennings",
        "id": "1125852789"
     },
     "to": {
        "data": [
           {
              "name": "Pepsi",
              "category": "Food/beverages",
              "id": "56381779049"
           }
        ]
     },
     "message": "Don't buy the new Pepsi can coming out with pictures of the Empire State building and The Pledge of Allegiance on them. Pepsi left out two little words on the pledge, \"Under God.\" Pepsi said they didn't want to offend anyone. So if we don't buy them they won't be offended when they don't receive our money that has the words \"In 

code to deserialize;

dim dserial as new javascriptSerializer()
Dim ddict as Dictionary(of String, Object) = dserial.Deserialize(Of Dictionary(Of string, object))(jsonData)

how do I now get the id, from, name, id, to …etc fields?
Any ideas please.

{updated}

appreciate the response. While I was waiting I tried something else and found what seems to be an easier method if I can only get some notes or examples on this.

dim results as list(of JToken) = jobj.("data").Children().ToList()
for each item as Jtoken in results
  uid = item("id")
  if item.type = JTokenType.Object then
      author = item.SelectToken("from.name")
      authorId = item.SelectToken("from.id")
  end if
  msg = item("message")

 next

Ok this seems much easier but I do not know how to traverse the token object. The message field is not read because the type is still Object I guess and I was wondering how can I go through this individual JToken and grab the fields.

  • 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-24T11:18:26+00:00Added an answer on May 24, 2026 at 11:18 am

    Deserialization creates the specified object based on the data. So, with what you have you could use code like the following (.Net 4.0 only, and this is C# since I don’t know VB):

    dynamic data = ddict["data"]; 
    string foo = data[0].from.id; 
    string bar = data[1].to.data[0].name == "Pepsi"
    

    and so on.

    If you don’t have the dynamic keyword you will have to use reflection, and that’s a long answer.

    However, it would be easier if you cast it to the original object type that you used to create that JSON. Or, if this is coming from an external source, create new types in your source code that map to that data tree, and deserialize to that.

    class Foo {
        string id;
        Bar from;
        ...
    }
    
    class Bar {
        string name;
        string id;
    }
    
    ...
    

    Then deserialize to (VB):

     Dim ddict as Dictionary(of String, Foo) = dserial.Deserialize(Of Dictionary(Of string, Foo))(jsonData)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've have finally got the datepicker to work on my MVC demo site. One
I've finally got this PHP email script working (didn't work on localhost…), but my
I finally got my site to work on my server, and it is now
I was given this code a while back. I finally got around to testing
I have finally got the green light to use Memcached in our project (after
I've finally got the datepicker to work on my MVC demo site and also
I have finally got in my mind what worried me about Dependency Injection and
I finally have a hardware guy that is insterested in controlling the firmware. This
I've got an issue involving a website that I have been using VS 2008
After much work I finally got a rather complicated query to work very smootly

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.