Parsing Json in Java Tutorial - Part 3: More complex Mappings

  Рет қаралды 12,660

CoderFromScratch

CoderFromScratch

Күн бұрын

Пікірлер: 45
@jaHiggs
@jaHiggs Жыл бұрын
This is an extremely helpful series. Thanks for taking the time!
@TheBaloonKiller
@TheBaloonKiller 3 жыл бұрын
Thank you really much for this Json Parsing series. That really helped me a lot!
@SuperCoderFromScratch
@SuperCoderFromScratch 2 жыл бұрын
You're very welcome!
@petarb.2632
@petarb.2632 4 жыл бұрын
I just watched your three videos on JSON, which (finally) made the whole topic clear to me. Thanks a lot! Subscribed & looking forward to more of your Java videos.
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Thanks so much for this feedback!!! It really made my day!!!
@petarb.2632
@petarb.2632 4 жыл бұрын
I am happy then, because your deserve it for your effort and great quality! I don`t know why this channel doesn`t have far more views, but a clue can be that most developers are working with frameworks like Spring (including myself), and thus searches for "Spring JSON parser/tutorial..." are far more popular (you can even see it in the auto-complete search feature in KZbin). It would be very nice if you e.g. continue these series here by moving towards how to do custom mapping with the ObjectMapper in Spring. The previous three videos can thus serve as a very nice "lower-level" base for how things are done, which was very beneficial to me.
@Mersal-tq9lm
@Mersal-tq9lm 2 жыл бұрын
Awesome series, short & straight to the point. 👍
@SuperCoderFromScratch
@SuperCoderFromScratch 2 жыл бұрын
Thanks so much!!!
@jaymalavia
@jaymalavia 2 жыл бұрын
Please continue this series.
@SuperCoderFromScratch
@SuperCoderFromScratch 2 жыл бұрын
Maybe I will :D
@MarkusKuehl
@MarkusKuehl 3 жыл бұрын
Really a very good tutorial for Jackson newbies like me....Thank you very much
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
Hey Markus, You're very welcome!
@balajis1800
@balajis1800 4 жыл бұрын
Expecting more videos from you
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Thanks so much!
@voiceguy554
@voiceguy554 3 жыл бұрын
Many thanks for the wonderful 3 lecture series about Parsing Jason!!! One novice query: what will be the use of test.json file say in our production project? TIA!!!
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
Hey. No particular use for a test.json file in particular. But you can send messages through rest clients in Json, and to work through those messages you need to serialize and deserialize those messages, etc . Does this make sense? Maybe I didn't understand your question correctly.
@PaganBuffaloes
@PaganBuffaloes 4 жыл бұрын
This video is a godsend! Thank you, and subscribed!
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Thanks so much for the feedback and the sub!
@ukaszt5026
@ukaszt5026 2 жыл бұрын
How refactor this method? I am trying get data from json file, not json string, i want to create a generic method to handle different element types. public static List jsonArrayToList(String json, Class elementClass) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, elementClass); return objectMapper.readValue(json, listType); } after run get Unrecognized token 'books': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'
@SuperCoderFromScratch
@SuperCoderFromScratch 3 ай бұрын
Hey, I hope you managed to get this working
@bhamasri509
@bhamasri509 Жыл бұрын
please upload tutorial for comparing two json files
@SuperCoderFromScratch
@SuperCoderFromScratch Жыл бұрын
There is no magic bullet here that I know of. Either you traverse the json objects and directly compare it, or you can use a diff library and compare the raw json files.
@escm1990
@escm1990 3 жыл бұрын
It is possible to append a new author with theirs books in test.json file? If you want to create a new author and add the books for it and do you want to append this in the actual file, how do you do? Thanks a lot! Please, a part 4 whit this answer.
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
Actually let me write this down. It is possible obviously, it is just a question of reading the file into the Pojo format, adding the new things, and then writing the file again :)
@Артур-з6щ7э
@Артур-з6щ7э 3 жыл бұрын
Very cool lessons, thanks a lot!
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
Hey thanks so much for the feedback!!!
@akmalstube
@akmalstube 4 жыл бұрын
This really helpful. Could you please make more video using GSON, SimpleJson and JsonPath ?
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Thanks for reaching out. Yes, GSON, should do a tutorial about that at some point. Let me get a look into that
@vgvgvg36
@vgvgvg36 3 жыл бұрын
you're very good dawg , so thx.
@SuperCoderFromScratch
@SuperCoderFromScratch 2 жыл бұрын
Happy to help
@mcdinggle9
@mcdinggle9 4 жыл бұрын
Thanks for the great videos! I was wondering how would you tackle multiple json inputs where using your author example, the first and second json input both have the same author but different books and you want to put all the books into only one author POJO. And add more books to the same author POJO if following inputs have the same author name.
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Hey @mcdinggle9 ! I think I understood what you asked. You should think of the POJO objects that come out of the parser as a representation of the JSON files. So, if you have two JSON files, you get two representations, so, two sets of POJOs. You get Two author object instances , which represent the two json files. In your head you understand that the authors are the same, but the parser doesn't know that, it is just making a verbatin representation of the json files. So, that logic that you are talking about, that needs to be implemented by you :-) .
@wchallenge7482
@wchallenge7482 3 жыл бұрын
Hello sir, thank you very much for your tutorial, I learned a lot because I have a lot of trouble using Json in JAVA... (it's much harder than in python!). I tried to adapt your code to read this type of file (below). Unfortunately, I succeeded, but by truncating the beginning and the end of the JSON file. I know it's not a professional technique, but I don't know if it's complicated to do. In any case I have not succeeded for the moment by using your functions... Do you think that by adapting your code I will be able to enter the second layer of data? Thank you very much ! { "france_power_exchanges": [ { "start_date": "2021-07-27T00:00:00+02:00", "end_date": "2021-07-28T00:00:00+02:00", "updated_date": "2021-07-26T13:13:20+02:00", "values": [ { "start_date": "2021-07-27T00:00:00+02:00", "end_date": "2021-07-27T01:00:00+02:00", "value": 12707.3, "price": 80.08 } ] } ] } I transformed my function to fit my file (I created a function getValues etc, but I don't know how to enter first in "france_power_exchanges" then in "values", because I need the prices. if you have the answer it would be great, I've been working hard on JSON for 3 days ^^
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
I think the right way to go about this would be to create a root POJO that only contains a List called france_power_exchanges. So, the root POJO would have the list france_power_exchanges of DayPOJOs , the Day pojo object will have the start date, end date, and updated date, and also a List of Value pojos. The value pojos will then have the start date, enda date, the value and the price. That should do the trick. From what I can gather from your questions, you are jumping straigh into the array, and not mapping the first node.
@sundarr7977
@sundarr7977 9 ай бұрын
I am getting this exception even i followed as you did :Please help me: Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDate` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: pojo.DayPojo["date"])
@SuperCoderFromScratch
@SuperCoderFromScratch 3 ай бұрын
Hey, I hope you got this fixed at some point in the last 6 months
@TahaZabuawala
@TahaZabuawala 3 жыл бұрын
Excellent tutorial, could you please share the code you wrote in this tutorial series
@SuperCoderFromScratch
@SuperCoderFromScratch 3 жыл бұрын
Yes, sure. It on the github repo : github.com/CoderFromScratch/json-in-java-tutorial
@josetomasp
@josetomasp Жыл бұрын
Thanks man. Save my life. I just want to know something. How I do if the json start with an array [. Regards.
@SuperCoderFromScratch
@SuperCoderFromScratch 3 ай бұрын
You need to give that array a name.
@lingaraja2556
@lingaraja2556 4 жыл бұрын
Thanks for the this tutorial. Really helpful. I used jsr.310 with version 2.11.0. I get error as below when I try to print the date. Is that due to any recent change ? java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Are you still having this problem?
@kotletor
@kotletor 3 жыл бұрын
Got the same error when using 2.12.0. After downgrade to 2.11.4 it started to work perfectly fine. Library might have some errors.
@ramasauge
@ramasauge 4 жыл бұрын
Ye, absolute gold. U got a udemy course?
@SuperCoderFromScratch
@SuperCoderFromScratch 4 жыл бұрын
Hey Augustas! Nope, all for free youtube videos! :-D
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН
GIANT Gummy Worm #shorts
0:42
Mr DegrEE
Рет қаралды 152 МЛН
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
Parsing Json in Java Tutorial - Part 1: Jackson and Simple Objects
15:32
CoderFromScratch
Рет қаралды 122 М.
Parse JSON to Java Object,ArrayList & Array Using Jackson Library
17:31
phCodeGyan Videos
Рет қаралды 22 М.
Kerbal Space Program 2 Was Murdered.
11:26
Bellular News
Рет қаралды 452 М.
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН