![]() |
|
[.NET] JSON Parsing Help - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] JSON Parsing Help (/showthread.php?tid=5912320) |
JSON Parsing Help - xDowwdeen - Nov 26, 2018 Hey Guys, I am a little stuck at the moment with Parsing some JSON due to the way it gets output. I am using Json.NET by Newtonsoft, and have used it many times before. So my problem is that with this JSON output here: https://pastebin.com/gE1QUCK3 When I create the class for it to use Json.NET I get this as an output here: https://pastebin.com/1Q4nCg7E Which doesn't work as the shows can be different depending on the user, and the obviously the class names also go as numbers. Does anyone know of a way that I could either create like the class at runtime or dynamically create an object. Then be able to loop through the object. For extra info this is the API Documentation here: http://sickbeard.com/api/ Many Thanks -xDowwdeen RE: JSON Parsing Help - Nick (Name) - Nov 26, 2018 Check out https://jsonutils.com/ for creating classes based off of JSON responses. RE: JSON Parsing Help - xDowwdeen - Nov 26, 2018 (Nov 26, 2018 11:11 AM)Nick (Name) Wrote: Check out https://jsonutils.com/ for creating classes based off of JSON responses. This was where i has created the class I have put on the pastebin RE: JSON Parsing Help - sdk - Nov 26, 2018 I don't know VB.NET so I can't provide any code sadly, but a simple way inmo would to be looping through "data" objects properties (because this is what they would be treated as) then creating a class (Result per example) and creating a Result object via the data.x children and adding that to a List. Code loop through response.dataRE: JSON Parsing Help - CodeAssassin - Nov 26, 2018 Have a look and play with this website to get the data structure you need. Hope this helps you :) https://app.quicktype.io?share=Ap8zYxudqjrTPcF7qLsT RE: JSON Parsing Help - S2K - Nov 27, 2018 I'm no longer coding in .net but I was used this website before: http://json2csharp.com RE: JSON Parsing Help - xDowwdeen - Nov 27, 2018 (Nov 26, 2018 10:26 PM)CodeAssassin Wrote: Have a look and play with this website to get the data structure you need. (Nov 27, 2018 04:23 AM)ᴍs-ᴅᴏs Wrote: I'm no longer coding in .net but I was used this website before: http://json2csharp.com Hi Guys, Thanks for your help, I am already been using the https://jsonutils.com/ website to help making my VB.NET classes, which works normally however with the JSON response that I get given it doesn't like create the list into an array. Please see here the output I get given from https://jsonutils.com/ >> [https://pastebin.com/1Q4nCg7E] It's creating its own class for each of the TV shows that are in the database. However this changes depending on the user that would be using the program. Hope this makes a bit more sense. -xDowwdeen RE: JSON Parsing Help - stefsot - Nov 27, 2018 data is of type Dictionary<string, object> Code Public Class DataEntryRE: JSON Parsing Help - xDowwdeen - Nov 27, 2018 (Nov 27, 2018 10:41 AM)stefsot Wrote: data is of type Dictionary<string, object> Ahhh many thanks. I can see how that works :) Thansk soo much for your help :) -xDowwdeen RE: JSON Parsing Help - th3s3cr3t0n3 - Dec 3, 2018 I don't get this. Like, I looked at the pastebin. Is all of this code really necessary? Can't you make a simple template class with matching data types and just serialise/deserialise? I use Newtonsoft, and I have to serialise/deserialise all the time. Works fine, using complex types. I just create basic template classes to work with. What you have there baffles me, I'd start from scratch. |