标题翻译
reading json file in java 8
问题
以下是翻译好的内容:
我正在制作一个简单的电话簿系统,用户和管理员通过命令提示符进行输入。
我正在使用一个名为login.json的文件,其中只有这些内容 -
{
"username": "admin",
"password": "12345"
}
我想知道在Java 8中,现在最好的方法是如何读取JSON文件并检查用户是否为管理员。
我还想知道如何在Java 8中使用LocalDate API存储用户提供的出生日期,如果可以的话。
我有一个用户模型类,其中包含了所有的字段,但是不太确定Java 8中的LocalDate如何帮助我设置从命令提示符传递的日期,似乎我们需要进行一些解析??
提前致谢。
英文翻译
I am making a simple phone book system where user and admin inputs via command prompt.
I am using a login.json file that has got just this -
{
"username" : "admin",
"password" : "12345"
}
I want to know whats the best way in java 8 now to read the json file and check if the user is admin or not.
I would also want to know how can i store the DOB given by a user in java 8 LocalDate API, if we can.
I have a model user class that has all the fields but not sure how the LocalDate from java 8 would help me set the date passed from command prompt, seems we have to do some parsing there ??
Thanks in advance
专注分享java语言的经验与见解,让所有开发者获益!
评论