Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Deserializing JSON to LocalDate  RSS feed

 
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure in what forum to post...
I'm trying to help an other poster here on the forum, I managed to figure out what is going wrong, he has a textfile containing jsonobjects, each of those objects contains a date.
When trying to read the file I get this error:

In my search what could cause the error I saw a remark of someone that he got the error because he didn't deserialize the date in the jsonObject.
When I remove the date, the error is gone, so in this case that's most likely also the prob.
I've never deserialized anything, how would you do that?
 
Saloon Keeper
Posts: 2406
296
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be helpful to see the JSON-encoded representation and the code being used to de-serialize.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't any code to deserialize yet... I wouldn't even know how to start
These are the jsonObjects:

and this is what I'm using to read the files:
 
Sheriff
Posts: 21641
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your dates aren't strings, but numerical calculations. That's not allowed in JSON. You need to put your dates between double quotes as well.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't write the json myself it's created


I added this to my playerClass:

but I still get the same error, even when I put my date between double quotes
 
Saloon Keeper
Posts: 20507
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't look like a legal JSON stream anyway. More valid would be:


Otherwise you have a collection of JSON snippets that are valid at the unit level but not valid as a JSON stream.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not supossed to be seen as a collection, but all seperate jsonobjects.
Everytime the player ends a game a line is being added
 
Tim Holloway
Saloon Keeper
Posts: 20507
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. I missed that. But we need your latest stacktrace. The only one we have is where it choked on not quoting the date strings. Which, alas, I forgot to add to my own example.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I should post a new question cause I maded some changes a and now the subjectline dosn't really cover my question anymore?!
I removed the LocalDate from my PlayerClass and save it now as a string.
but it seems that my jsonObject isn't bindded corectly to the javaObject, cause I'm getting nullpointers.
I'll post the whole code to make it a bit easier for you guys to help.

PlayerClass:


MenuController:

AddController:

ShowController:

Stacktrace:
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lol weird as hell... Before, cause it was ment as an quick example, aal the code was in my sample.Controller.
I knew if I would have posted it that way here, surely someone would a remark about it, so I sperated my code a bit.
I ran it again to see if the rest still worked and now everything works!?
At least allmost, no errors anymore, but the nameColumn isn't filled yet
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also managed to figure that out, in my object I was referring to userName, but the instance variable is name, so I changed the instance variable and adjusted the propertyValueFactory and tada
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!