Gson Tutorial - Getting Started with Java-JSON Serialization & Deserialization

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ต.ค. 2024

ความคิดเห็น • 71

  • @yasnoponyatno6208
    @yasnoponyatno6208 8 หลายเดือนก่อน

    Man, that was something. Really hard to find so concise and useful tutorial.

  • @goxr3plus_studio
    @goxr3plus_studio 7 ปีที่แล้ว +17

    This is very clear tutorial about Gson library , thank you sir :)

    • @FutureStudio
      @FutureStudio  7 ปีที่แล้ว +2

      You're welcome! :)

    • @Badrkhan2016
      @Badrkhan2016 6 ปีที่แล้ว

      GoXR3Plus this is the best one I saw as compare to Parbesh, Buki tutorials.
      :D

  •  6 ปีที่แล้ว +3

    Bet json with java explanation in all internet. Thank you!

  • @deontaywilson4624
    @deontaywilson4624 7 ปีที่แล้ว +1

    These tutorials have been a godsend. Thank you so much, Norman. Two thumbs up.

  • @peterwanden7285
    @peterwanden7285 6 ปีที่แล้ว +1

    Thank you for making this video series. They are very well made, simple to follow and have saved me a lot of time.

  • @ni_kabiu_john
    @ni_kabiu_john 4 ปีที่แล้ว +2

    These Germans are good in making educational tutorials. Am a long time Sub of CodingInFlow and today I SUBSCRIBE TO YOURS TOO. KEEP UP AM LEARNING JSON

  • @ayoubanbara1685
    @ayoubanbara1685 5 ปีที่แล้ว +1

    thanks and especially on vertically split screen way I did not know before

  • @bernardlomo2334
    @bernardlomo2334 7 ปีที่แล้ว +6

    Great videos there Norman. I really appreciate.

  • @nj20baller
    @nj20baller 7 ปีที่แล้ว +2

    Thank you, I can understand that accent.

  • @mushfiqfuad249
    @mushfiqfuad249 2 ปีที่แล้ว

    Thanks a lot. This one is the simplest one.

  • @nj20baller
    @nj20baller 7 ปีที่แล้ว +1

    I am damn impressed, I want to do it with android, will search channel, your a good teacher

    • @FutureStudio
      @FutureStudio  7 ปีที่แล้ว

      +Nick Jordan aka King of Spades ♠ thank you :)

  • @marcotohom3631
    @marcotohom3631 4 ปีที่แล้ว

    Con el simple hecho de tener subtítulos te has acreditado mi suscripcion. Una genialidad tu forma de explicar.

  • @avotihook
    @avotihook 5 ปีที่แล้ว

    Спасибо, дружище за объяснение!

  • @Badrkhan2016
    @Badrkhan2016 6 ปีที่แล้ว +2

    Great videos. Could you please make a lecture on junit testing and espresso (not recorded) testing. I am learning from you and you video quality and way of teaching is the best. Honestly you are helping us this is very good moment for us. I don't have money to buy lectures and your lectures are the best one I saw on youtube.
    Thank you to you and your team (if you have team) for spending your precious time on these videos.
    #junit #espresso teseting please

    • @FutureStudio
      @FutureStudio  6 ปีที่แล้ว +1

      Thanks for the compliment! Unfortunately, we don't have any plans to cover junit or espresso at the moment, sorry.

  • @Kumarkumar-gf3kk
    @Kumarkumar-gf3kk ปีที่แล้ว

    Great video . Thanks a lot Appreciate!

  • @TheWalace10
    @TheWalace10 3 ปีที่แล้ว

    Thank you! you helped a lot on my test!

  • @marvel438
    @marvel438 5 ปีที่แล้ว

    So simple. Amazing

  • @ozcanshalak7280
    @ozcanshalak7280 4 ปีที่แล้ว

    More than excellent

  • @zikooo84oo
    @zikooo84oo 5 ปีที่แล้ว

    Excellent video thanks sir!

  • @angelocortez1861
    @angelocortez1861 2 ปีที่แล้ว

    Is there a way to auto-create this class in 1:50 given some sort of JSON?

  • @dimatarasiuk8027
    @dimatarasiuk8027 3 ปีที่แล้ว

    Maybe I don't understand smth but what the point of json file if you initialize fields in java code. If some data will change in json file you still working with data in created object. I didn't notice the step of reading json data from the file. Could you pls explain how to do that? And thanks for the video

  • @sumiyak7842
    @sumiyak7842 6 ปีที่แล้ว

    such a clear vedio....thank u sir........

  • @lmsg123
    @lmsg123 5 ปีที่แล้ว

    excelent tutorial and video! Thanks !

  • @nimit8849
    @nimit8849 6 ปีที่แล้ว +1

    Excellent!

  • @Anil08901a1206
    @Anil08901a1206 6 ปีที่แล้ว +1

    Really Appreciated...bro great video...

  • @hank3339
    @hank3339 6 ปีที่แล้ว +1

    I had to use GsonBuiler for the instantiation: Gson gson = new GsonBuilder()
    .disableHtmlEscaping()
    .serializeNulls()
    .create();
    cheers!

  • @cholschuh
    @cholschuh 7 ปีที่แล้ว

    Great Video!! Thank you!

  • @ManufactoryMaster
    @ManufactoryMaster 2 ปีที่แล้ว

    That's cool, but what if our json lie on some url. then what would we do?

  • @sedem_quame
    @sedem_quame 5 ปีที่แล้ว +1

    This tutorial, is awesome cheers ✨✨✨.

  • @alenmistric6231
    @alenmistric6231 6 ปีที่แล้ว

    Suppose you have several JSON files and model classes. Any tips on how I could make deserialization more generic in terms of the arguments that method "fromJson" takes in?

  • @CXM-vu3pt
    @CXM-vu3pt 4 ปีที่แล้ว

    Thank you!!

  • @cajoblue
    @cajoblue 6 ปีที่แล้ว

    how can i serialize a date attribute that come from a API(webservice) in microsoftFormat

  • @adityapathak7638
    @adityapathak7638 7 ปีที่แล้ว

    Suppose I have a User Class which have Username(string) and password(string), but while converting this object to json via GSON , i want password to bet get encrypted(say MD5) .
    Any Idea how to do that?

    • @FutureStudio
      @FutureStudio  7 ปีที่แล้ว +2

      You could either encrypt the password when it gets set in the object (via a setter or the constructor), or you could try custom deserialization: futurestud.io/tutorials/gson-advanced-custom-deserialization-basics
      PS: MD5 is not considered safe anymore, so it'd advise against using MD5.

  • @Mohamed-uf5jh
    @Mohamed-uf5jh 6 ปีที่แล้ว

    Good tuto, thanks

  • @boiniq
    @boiniq 6 ปีที่แล้ว +1

    why in the first example the name was the first thing you wrote in gson and in the second it was the last how does this works?

    • @FutureStudio
      @FutureStudio  6 ปีที่แล้ว

      The order doesn't matter.

  • @Adyel-YT
    @Adyel-YT 6 ปีที่แล้ว

    Great Video, Saved lot of my time : )

  • @nodarmaruashvili567
    @nodarmaruashvili567 6 ปีที่แล้ว +1

    How did you format json in UserSimpleWithJson.json file?

    • @FutureStudio
      @FutureStudio  6 ปีที่แล้ว

      Format code shortcut: th-cam.com/video/KRDJXKt4bTk/w-d-xo.html

  • @alperaydin7011
    @alperaydin7011 4 ปีที่แล้ว +1

    Can you show List class object serialize and deserialize please.

  • @living_by_watching_old_vods
    @living_by_watching_old_vods 6 ปีที่แล้ว

    amazing...thanks

  • @shawnmoore2429
    @shawnmoore2429 7 ปีที่แล้ว +1

    Anyone know if its possible to get parameter hints/labels like in the video, but for Android Studio? They are very useful.

    • @FutureStudio
      @FutureStudio  7 ปีที่แล้ว

      This is an IntelliJ feature. It's included in the Android Studio 3.0 builds!

  • @ugurcanozyurteri9543
    @ugurcanozyurteri9543 6 ปีที่แล้ว

    Thanks for great videos !
    Im a beginner with coding and have 2 questions:
    1- Does the gsonClass (UserSimple) have to have same number of variables with json data ? What happens if UserSimple has 5 different variables and Json has 10 keys ? Can we fetch only 5 keys which we want from Json data ?
    2- Does gsonClass(UserSimple) class have to have exactly same variable names with in Json's keys ? I mean, if our Json data has keys like :
    Json data:
    {
    home_team: Real Madrid
    away_team : Juventus
    odd_1: 1.60
    odd_x: 2,30
    odd_2: 3,50
    odd_u+2,5 : 1.80
    odd_o+2,5 : 2.30
    match_time : 18:30
    match_date : 20-12-2017
    }
    I think it doesnt have to but if our class has to have same variable names with json data keys, I can not create a variable which has name like : "odd_u+2,5" in Java.

    • @FutureStudio
      @FutureStudio  6 ปีที่แล้ว

      Thank you. Regarding your questions:
      1) No, it does not have to be the same number. Gson will only convert the properties your UserSimple class describes. If the JSON has more properties, those will be ignored. In other words, if the JSON has 10 properties, but you only care about five of them, just add those to your Java model.
      2) By default, the Java model property has to have the same name as the JSON. However, you can customize it with a simple annotation. The video for it is here: th-cam.com/video/qTXQGmYSazk/w-d-xo.html

  • @subhashmadineni9778
    @subhashmadineni9778 ปีที่แล้ว

    they asked me this exact type of problem in netflix SDE interview, i have no clue what they are talking about. I wish i watched this tutorial before.

  • @Ihbramm
    @Ihbramm 5 ปีที่แล้ว

    Hello and thanks for the nice video! Could i ask you something? If you got and JSON object with 100 attributes is it possible to convert it to a java object where i have only 3 attributes like title,id and date ? Can we somehow match those things ? Or do the Java object has to be exatly the same object like the JSON object ?
    Thanks,
    Alex

    • @ahmadxrizvi
      @ahmadxrizvi 2 ปีที่แล้ว

      It's possible right? I'm very new with json and api handling and finding all this very overwhelming

  • @AdityaKumar-mt1rh
    @AdityaKumar-mt1rh 7 ปีที่แล้ว

    how did u make your transparent background video?

    • @FutureStudio
      @FutureStudio  7 ปีที่แล้ว

      With a green screen and chroma key: en.wikipedia.org/wiki/Chroma_key

  • @xJustted
    @xJustted 5 ปีที่แล้ว

    Thanks realy helped me=)

  • @gabrielpereiramendes3463
    @gabrielpereiramendes3463 4 ปีที่แล้ว

    #Excelent!

  • @guillaumecerdan1429
    @guillaumecerdan1429 6 ปีที่แล้ว

    Hi ! I understood and really appreciate your video man :)
    But I got an error when I did the same thing as you, I got :
    "Could not find method compile() for arguments [com.google.gson:gson:2.8.0]"
    But I have :
    buildscript {
    repositories {
    google()
    jcenter()
    mavenCentral()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    compile 'com.google.gson:gson:2.8.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    }
    In my build.gradle
    Does anyone have an idea please ?
    Have a good day !

    • @FutureStudio
      @FutureStudio  6 ปีที่แล้ว

      +Guillaume Cerdan it's not the correct line. It should be compile 'com.google.code.gson:gson:2.8.0'

  • @NuiceT
    @NuiceT 6 ปีที่แล้ว +13

    Wusste es du bist Deutscher xD

  • @ThueringerNeuland
    @ThueringerNeuland 5 ปีที่แล้ว

    Ze german accent is strong but it’s a good video (;

    • @FutureStudio
      @FutureStudio  5 ปีที่แล้ว +2

      Thank you for ze comment :)

  • @lllen-s8m
    @lllen-s8m 7 ปีที่แล้ว

    dependency for json doesn`t work

  • @Saiyan2003
    @Saiyan2003 2 ปีที่แล้ว

    Gracias csmr gaaaaaa!!!!

  • @ryo3560
    @ryo3560 5 ปีที่แล้ว +2

    alguien mas que hable espanol?JAJS me siento solo:(

  • @onionsandwich
    @onionsandwich 6 ปีที่แล้ว

    I now know your email. Mwahahaha !

  • @h0riiz0n97
    @h0riiz0n97 5 ปีที่แล้ว

    Nao é isso que quero!

  • @mohammedkhalifa8790
    @mohammedkhalifa8790 6 ปีที่แล้ว

    for what gson ?
    to convert my server api json to gson ? and convert gsom to json object again ? lol
    someone tell my why ?
    why gson ?
    for what ?