How to Parse JSON Data in C# - Coding Gems

Поділитися
Вставка
  • Опубліковано 10 гру 2024

КОМЕНТАРІ • 34

  • @linusfahlander2449
    @linusfahlander2449 9 місяців тому +7

    Hours spent searching for good tutorials and i finaly find this channel. Amazing video!

  • @tjlaser99
    @tjlaser99 Рік тому +5

    Never seen anyone so good at explaining!

  • @justfeeldbyrne2791
    @justfeeldbyrne2791 8 місяців тому +1

    Thank you for this video, this really helped me. I'm just starting out in C# and I'm sure what I was trying to do could be done a lot better, but this was the easiest for me to understand!

  • @garret_thorne
    @garret_thorne Рік тому +5

    fantastic! clear, concise, and extremely helpful. Thank you!

  • @BF0001
    @BF0001 6 місяців тому

    FANTASTIC. Very well done and explained so clearly. 10/10

  • @seanrendall5495
    @seanrendall5495 6 місяців тому

    Super helpful. All I wish this included was how to get just a portion of the JSON file as a string.

  • @HaploBartow
    @HaploBartow 9 місяців тому +1

    This is a great video and very clear, but I would like to see how you handle this case but with multiple strings of the same format you've shown here. Do you have to create multiple lists? Or can you do it with a list of lists (e.g. nested)?

  • @mikelammi3088
    @mikelammi3088 5 місяців тому

    Thanks for your content! Clear and concise 👏

  • @claudio1983
    @claudio1983 Місяць тому

    First of all: fantastic gem! Subscribed to the channel!
    Then, the question (maybe it's already answered in another video, so in the case could you point it out?): I'm playing around with json and encountered a problem. In short: I have a json like this stored in a database table {"fields":[{"field1":"value1"},{"field2":"value2"},etc.etc.]}, where the name and number of fields could change between rows. So i could have the field2 but not the field1, or field34, and maybe field20 repeated 2 or more times.
    The question is: how should look a class representing this kind of data? I tested many ways (list of keyvaluepair for example, or list of another class defining the single field-value couple) but always get some trouble while deserializing and also while querying with tsql on sql server (json_value, json_query, etc. don't seems to support for iteration on the elements of the array...). So I'm a bit stuck on that... could you give me some advise or give any direction to look to?
    Thanks in advance for any suggestion and again: amazing video! Thank you for that!

  • @idegarceus5895
    @idegarceus5895 3 місяці тому

    Thank you! That was very helpful.

  • @gameofjoy3561
    @gameofjoy3561 4 місяці тому

    Very nice video. You made it so easy. Thank you so much. 👍

  • @thomaswoods1365
    @thomaswoods1365 4 місяці тому

    This is awesome. Thank you! Thank you!

  • @StephenBeale
    @StephenBeale 3 місяці тому

    Very useful, thanks - the only thing I would add is that I had access denied when trying to read in from a file (even when running VS 2022 as Administrator). Any tips on sorting that would be great (I'm on a work computer so it's hard to know what else might be going on in the background)

  • @alexsnowblind
    @alexsnowblind 9 місяців тому

    Thank you! Well explained!

  • @markus72wi
    @markus72wi Рік тому

    Thanks for this clear tutorial , helped a lot

  • @ahmedadel2487
    @ahmedadel2487 Рік тому

    FANTASTIC VIDEO

  • @adyman0010
    @adyman0010 3 місяці тому

    It would be also nice if you could show us how to write data into the .json file :)

  • @Za3DoRzX
    @Za3DoRzX Рік тому

    Great explanation.

  • @mindblower113
    @mindblower113 Рік тому

    Nice video man thanks.

  • @VisibleWater
    @VisibleWater Місяць тому

    good explanation

  • @Dismanameboi
    @Dismanameboi 2 місяці тому

    Amazing channel

  • @netrunner1987
    @netrunner1987 4 місяці тому

    Ran into this early morning, helped me a bunch. Kinda stuck now, what do you do when you have "location": null? When I deserialize and try to read root.data.location, I get a System.NullReferenceException: 'Object reference not set to an instance of an object.'
    Document_Parser.readjson.Data.dateOfBirth.get returned null.
    Thanks

  • @EmranSalah
    @EmranSalah Рік тому

    Very helpful.
    Thank you very much

  • @gametech7725
    @gametech7725 Рік тому

    Amazing. How to enable Auto complete of visual studio? Can you guide please?

    • @tuomaslehtonen1707
      @tuomaslehtonen1707 Рік тому

      It is called IntelliSense. Should be under Tools -> Options -> Text Editor -> C# -> IntelliSense.

    • @gametech7725
      @gametech7725 Рік тому

      @@tuomaslehtonen1707 i cant find it under Tools. I have one in Visual studio -> Preference -> Text editor -> IntelliSense.
      It’s enable but not working like shown in your video.
      Didn’t saw anything related to C# in above path although I’m working with Unity & C#. Maybe a module is missing? 🤔

  • @ElCidPhysics90
    @ElCidPhysics90 Місяць тому

    Very nice

  • @peremos7781
    @peremos7781 8 місяців тому

    How to deserialize this Json, what to do with the word "producto" before the properties?
    {
    "producto": {
    "iDpRODUCTO": 6,
    "codigoBarra": 54323,
    "nombre": "cera",
    "marca": "avon",
    "categoria": "belleza",
    "precio": 3400
    }
    }

  • @nearissad3127
    @nearissad3127 Рік тому

    oh my god thank you

  • @athanasmb
    @athanasmb Рік тому

    thansk!!

  • @jeffstress6460
    @jeffstress6460 Місяць тому

    666s like it...

  • @wirelessmistress608
    @wirelessmistress608 2 місяці тому

    My dear Hobbyist programmer ... you should really put your DTOs in a common or Shared Project and not straight in your Console Application So you can have it referenced by other server or clients without having to export your console to your clients or servers you talk to and hence avoid circular references of your executable ... It's lovelty to see you just realized you could seriallize and deserialize Json .. well it;s not just Json .. it's Xml it's Objects and basically anything you can tuirn to a series of bytes and also strings ... (which are bytes anyway...lol) ... congratulations you discovered the oldest web Api practice just yesterday.. I guess better late than never ...welcome to reality man ... lol bye bye

  • @kvelez
    @kvelez Рік тому +1

    using ConsoleApp1;
    using System.Text.Json;
    var person = new Person("Kevin", 19);
    var _serializeJSON = JsonSerializer.Serialize(person);
    File.WriteAllText("file.json", _serializeJSON);
    var readJSON = File.ReadAllText("file.json");
    Person _deserialize = JsonSerializer.Deserialize(readJSON);
    Console.WriteLine($"{_deserialize.Name} is {_deserialize.Age} years old.");
    Console.ReadKey();