Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Parsing JSON

Parsing JSON

Scheduled Pinned Locked Moved C#
jsoncsharphelpquestionannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harsimranb
    wrote on last edited by
    #1

    I am trying to parse the following JSON string, to get the genre, id, and photo in a list. [ { id: "6" genre: "Music" photo: "music.jpg" }, { id: "2" genre: "Entertainment" photo: "enter.png" }, { id: "8" genre: "Games" photo: "games.gif" }, { id: "7" genre: "Movies" photo: "movie.gif" }, { id: "9" genre: "News" photo: "news.jpg" }, { id: "5" genre: "Mail" photo: "Mail.gif" } ] I tried using the JSON.Net library, but could not really use it, due to lack of examples. If anyone can help in getting the id, genre, and photo in a list, that would be really helpful! *Also, I am using the Compact Framework, WM 6. Thanks, Harsimran Singh

    1. The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson 2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll 3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris (Computer code: 00001111 - translation: Hello! :P ) REMEMBER: "Computers are made for us, we are not made for them
    OriginalGriffO K 2 Replies Last reply
    0
    • H harsimranb

      I am trying to parse the following JSON string, to get the genre, id, and photo in a list. [ { id: "6" genre: "Music" photo: "music.jpg" }, { id: "2" genre: "Entertainment" photo: "enter.png" }, { id: "8" genre: "Games" photo: "games.gif" }, { id: "7" genre: "Movies" photo: "movie.gif" }, { id: "9" genre: "News" photo: "news.jpg" }, { id: "5" genre: "Mail" photo: "Mail.gif" } ] I tried using the JSON.Net library, but could not really use it, due to lack of examples. If anyone can help in getting the id, genre, and photo in a list, that would be really helpful! *Also, I am using the Compact Framework, WM 6. Thanks, Harsimran Singh

      1. The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson 2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll 3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris (Computer code: 00001111 - translation: Hello! :P ) REMEMBER: "Computers are made for us, we are not made for them
      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Have you looked at JavaScript Object Notation Support for .NET 2.0[^]

      You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • H harsimranb

        I am trying to parse the following JSON string, to get the genre, id, and photo in a list. [ { id: "6" genre: "Music" photo: "music.jpg" }, { id: "2" genre: "Entertainment" photo: "enter.png" }, { id: "8" genre: "Games" photo: "games.gif" }, { id: "7" genre: "Movies" photo: "movie.gif" }, { id: "9" genre: "News" photo: "news.jpg" }, { id: "5" genre: "Mail" photo: "Mail.gif" } ] I tried using the JSON.Net library, but could not really use it, due to lack of examples. If anyone can help in getting the id, genre, and photo in a list, that would be really helpful! *Also, I am using the Compact Framework, WM 6. Thanks, Harsimran Singh

        1. The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson 2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll 3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris (Computer code: 00001111 - translation: Hello! :P ) REMEMBER: "Computers are made for us, we are not made for them
        K Offline
        K Offline
        Kythen
        wrote on last edited by
        #3

        The JSON.Net library isn't too hard to use. The documentation can be a bit hard to follow at times, but at lot of the mess comes from the really bad LINQ examples. Create a class to encapsulate the id, genre, and photo fields. I'll just call it Section for this example. Then use this code to get your list of Section objects:

        List<Section> products = JsonConvert.DeserializeObject<List<Section>>(jsonString);

        H 1 Reply Last reply
        0
        • K Kythen

          The JSON.Net library isn't too hard to use. The documentation can be a bit hard to follow at times, but at lot of the mess comes from the really bad LINQ examples. Create a class to encapsulate the id, genre, and photo fields. I'll just call it Section for this example. Then use this code to get your list of Section objects:

          List<Section> products = JsonConvert.DeserializeObject<List<Section>>(jsonString);

          H Offline
          H Offline
          harsimranb
          wrote on last edited by
          #4

          Thanks! That worked perfectly for me!! :-D

          1. The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson 2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll 3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris (Computer code: 00001111 - translation: Hello! :P ) REMEMBER: "Computers are made for us, we are not made for them
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups