JSON Tutorial in Python

Поділитися
Вставка
  • Опубліковано 26 вер 2024
  • In this fundamental video, we talk about how to work with JSON files in Python.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine...
    💻 The Algorithm Bible Book: www.neuralnine...
    👕 Programming Merch: www.neuralnine...
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine...
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/Neu...
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/

КОМЕНТАРІ • 85

  • @benjamindreyer9884
    @benjamindreyer9884 3 роки тому +45

    Brother you seriously make the most interesting videos, they are so informative and well put together. Can’t believe you aren’t bigger, keep on the grind

    • @NeuralNine
      @NeuralNine  3 роки тому +13

      Good things take time ^^

    • @Holasticlogger
      @Holasticlogger 3 роки тому +1

      @@NeuralNine And It won't take much time..Wish you a great quick success !!!

  • @rustam-z
    @rustam-z 2 роки тому +16

    We can use dump() and load() methods too, they are basically used to write to json file ("w") and read from json file ("r") respectively:
    with open("mike.json", "w") as f:
    json.dump(dictionary, f)
    and
    with open("mike.json", "r") as f:
    my_object = json.load(f)

  • @BrandonJacobson
    @BrandonJacobson 3 роки тому +7

    It's like you can read minds. I needed this for an automation project I'm working on. Thanks for the videos and you're an inspiration to my own Python programming channel.

  • @CaptMirage
    @CaptMirage 3 роки тому

    i love how when i have a feeling that a video im gonna watch to learn something is good and it turns out its underrated
    i love your vids your a life saver

  • @mattmovesmountains1443
    @mattmovesmountains1443 3 роки тому

    I never really knew what json was for until this video. I hear frequent references to it on other videos, but never a real explanation. Thank you!

  • @lenninstevensabogalprieto4757
    @lenninstevensabogalprieto4757 2 роки тому

    I came up just to learn How to use json but I ended up solving lots of questions I had from oop and learning json, you're the best!

  • @tsmghost
    @tsmghost 3 роки тому +1

    another quality video, I was seriously waiting for some video on json!

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

    Dude ... awesome video... still learning lots and lost from your programming. Thx

  • @deeperblue77
    @deeperblue77 3 роки тому +2

    Really helpful and worthwhile watching as always!

  • @mohitkrishnia8632
    @mohitkrishnia8632 2 роки тому

    i search on the whole youtube about json but all only showing a simple logic not with making a class and and its data to json. I like Your Video most I get all the info which I need . Thank you sir . love you

  • @arnavmeena525
    @arnavmeena525 3 роки тому +1

    Why is this guy so good? It's like..., It's like.... I don't have words.

  • @MitraElectronics
    @MitraElectronics 3 роки тому +1

    Thanks for the video I always wanted to know how to store classes as json. You can also use json.dump to store json data in files like this:
    data = {'name':'Bob'}
    with open("file.json", "w") as f:
    json.dump(data, f, indent=4)
    f.close()

    • @adrielbradley6677
      @adrielbradley6677 2 роки тому +1

      I think you can skip the f.close() line if you're using with open() as f

  • @markthomas9641
    @markthomas9641 2 роки тому

    Great explanation, thank you. DeltaJSON is really useful for developers working with JSON, it does compare, merge and graft.

  • @Jxrdy
    @Jxrdy 3 роки тому +3

    Perfect timing! :D

  • @surftijmen
    @surftijmen 3 роки тому

    You always have those great video ideas! Keep on going man it really helps!

  • @Volodymyr_Honcharov
    @Volodymyr_Honcharov 3 роки тому

    Thanks. It's always interesting to watch your videos

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

    excellent content. straight to the point. Thank you very much

  • @danish_parve
    @danish_parve 3 роки тому +1

    Big THANKS!!

  • @juliansteden2980
    @juliansteden2980 3 роки тому +1

    Great video!
    This would be a cleaner solution to load json:
    class Person:
    ...
    @staticmethod
    def load_from_json(filename):
    ...
    return Person(name, age, weight)
    p = Person.load_from_json("your_filename.json")

    • @JohnMacPherson-hr4yz
      @JohnMacPherson-hr4yz Рік тому +1

      just to add to Hi Julian's comment: for those who might have issues, the full implementation of "load_from_json" function would be:
      @staticmethod
      def load_from_json(filename):
      with open(filename, 'r') as f:
      data = json.loads(f.read())
      name = data['name']
      age = data['age']
      weight = data['weight']
      return Person(name, age, weight)
      p = Person.load_from_json("your_filename.json")
      p.print_info()

  • @me-by7sd
    @me-by7sd Місяць тому

    This video is excellent. Could you please make a video about loading any arbitrary json data using Python ?

  • @OscarRodriguez-jr6si
    @OscarRodriguez-jr6si 2 роки тому +4

    Awesome vid! Could you explain how to loop through a Python dictionary that was imported from JSON?

  • @shubhamyedve7638
    @shubhamyedve7638 3 роки тому

    wo hoo epic needed this so bad ur so great man hats off

  • @iltrovatoremanrico
    @iltrovatoremanrico 3 роки тому

    Huge thanks for the great content, mate!

  • @damienkubik1380
    @damienkubik1380 2 роки тому

    Great example and explanation 😁
    Thanks

  • @ElliotWeishaar
    @ElliotWeishaar 2 роки тому

    Great Tutorial. I think it's worth noting that python dictionaries use single quotes by default and JSON uses double quotes as part of the JSON spec. It's unlikely, but it's possible that you can run into issues changing between JSON and a python dictionary due to singe quotes vs double quotes. Ask me how I know that ;)

  • @Farreach
    @Farreach 2 роки тому

    i did something very similar but i sent it over the network to another device that received it and stored it on its device ..I was doing it for my capstone for computer science.. I was trying to build a very basic SIEM tool .. a way to monitor network traffic

  • @Richard-yz2gy
    @Richard-yz2gy 3 місяці тому

    hi there, why couldnt you add both p1 and p2 into one json file ??

  • @1UniverseGames
    @1UniverseGames 2 роки тому

    for say you used [0] Object, what if I want to get 0 to max number Object item to print the data for that specific "formatted_address", how can do it.?

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

    Can we get more videos on json examples for python?

  • @mariumbegum7325
    @mariumbegum7325 2 роки тому

    Fantastic tutorial!

  • @adityaraut9364
    @adityaraut9364 3 роки тому +1

    NOICE 👍👌

  • @muhammadvaliallah2781
    @muhammadvaliallah2781 3 роки тому

    Hi can you minimise the folder structure menu on the left, it gives more screen estate

  • @14ftdude
    @14ftdude 3 роки тому +1

    can u make a video on websockets with golang?

  • @NishithSavla
    @NishithSavla 3 роки тому

    There is also dump and load to work with files directly

  • @piotr780
    @piotr780 2 роки тому

    what about saving multiple json objects to the same file ?

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

    Impressive

  • @hothivanhanh5031
    @hothivanhanh5031 3 роки тому

    like number 100!😍

  • @bsx1604
    @bsx1604 3 роки тому

    Sir, I have some question when i install vidstream by using pip install vidstream i face this Error ERROR: Command errored out with exit status 1 How can i fix this sir. thankyou

    • @griffinblackbird9771
      @griffinblackbird9771 3 роки тому

      Make sure you haven't saved a .py file as 'Vidstream' in the directory you are working.

  • @tibettenballs4962
    @tibettenballs4962 2 роки тому

    you sire are truley under estimated. appreciate both the big and small tutorials.

  • @gus.stviaaa
    @gus.stviaaa 3 роки тому +1

    I wanted to learn JSON and it's like he read my mind lol

  • @codenerd7823
    @codenerd7823 3 роки тому

    Pls scale up the fonts
    Can't see them on phone screen

  • @guilherme5094
    @guilherme5094 3 роки тому

    Thanks!

  • @AJain-18
    @AJain-18 3 роки тому

    Nice Video !!👍🏻👍🏻

  • @abhinavchoudhary8014
    @abhinavchoudhary8014 3 роки тому +1

    Bro I need a good tutorial of MySQL with python
    Please make a tutorial on it

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

    Thx_. Nice.

  • @ibexl8631
    @ibexl8631 3 роки тому +1

    Bro how did you hack my search history

  • @drxftyplaya5898
    @drxftyplaya5898 3 роки тому +1

    I literally searched this up 2 minutes ago lmao

  • @CubeRiser
    @CubeRiser 2 роки тому

    5:59 at this point it's better to use json.load(f) instead of json.loads(f.read())

  • @robomartens
    @robomartens 3 роки тому

    How can you create multiple person objects and export them into a single JSON file?

    • @Richard-yz2gy
      @Richard-yz2gy 3 місяці тому

      exactly knowbody seems to know, your like the third person to ask this obvious question lol

    • @Richard-yz2gy
      @Richard-yz2gy 3 місяці тому

      if you have worked it out please let me know thanks

  • @JustIn-case
    @JustIn-case 3 роки тому

    if you find stuff not defined add >>>>>>> false = False||true = True null = None

  • @User-actSpacing
    @User-actSpacing Місяць тому

    He obviously doesn’t know this clearly but. Dumps, loads work with strings, dump, load work with files.

  • @prod.ot5
    @prod.ot5 3 роки тому +1

    Probably not first but I’m early

  • @emperorj4783
    @emperorj4783 3 роки тому

    I was just thinking about JSON...

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

    Man I have some questions for you

  • @AJain-18
    @AJain-18 3 роки тому +1

    First 😁👋👋

  • @joyo2122
    @joyo2122 3 роки тому

    ez

  • @749srobin
    @749srobin 3 роки тому

    Its always good to pronounce T in my_dict ..

  • @aryankothari1725
    @aryankothari1725 3 роки тому

    uwu

  • @User-actSpacing
    @User-actSpacing Місяць тому

    Terrible teacher 😂

  • @minuet6919
    @minuet6919 3 роки тому +2

    Your getting close to 100k keep on going!

  • @vijayskrishnan3192
    @vijayskrishnan3192 2 роки тому +1

    Thanks for your time. Could you please explain in more detail or in a slower pace the details of the syntax
    if this content is intended for complete beginner like me ?

  • @robfei-u6b
    @robfei-u6b Рік тому

    Thanks!! best video about json in python. one question, if want to send (json_str via tcp/udp, should I using encode() and decode() when receive?