Java - read JSON file - Multiple Records

preview_player
Показать описание
#ReadJSON #JavaReadJSON #JavaReadMultipleRecordsJSON

Java - read a JSON file - Multiple Records

Like, Share, And Subscribe | Professor Saad Yousuf
*******************CODE******************

public class ReadJSONExample {

public static void main(String[] args) {
JSONParser jsonP = new JSONParser();

//Read JSON File
Object obj = jsonP.parse(reader);
JSONArray empList = (JSONArray) obj;
//Iterate over emp array
}
catch (FileNotFoundException e) {
} catch (IOException e) {
} catch (ParseException e) {
}
}
private static void parseEmpObj(JSONObject emp) {
//get emp firstname, lastname, website
}
}
Рекомендации по теме
Комментарии
Автор

Thank you! This was exactly what I need for my Java project. :)

anycaroliny
Автор

Ocker rences. This video saved my butt. Thank you so much! Hearts in chat

jordanaugust
Автор

Hi sir..I am doing poc to read the json object...as of now I am facing one issue I don't know how to read the json boolean value ..please tell me the code sir.

raghuramanraman
Автор

Hello. You tutorial on dom parser for reading XML was very informative. Please also do a tutorial on creating an XML(with nested nodes)using another XML as input with dom parser in Java. Thanks in advance.

faisaljamal
Автор

how handle JSONObject["firstname'"] not found. / value null

YazGuitarChanel
Автор

Hey Salam. How do we proceed if the objects arent seperated with "employee" tag, as in it the list contains different employee objects but they arent segregated under employee term or any other term for that matter.

saadhq
Автор

I am getting an error of "Unrecognised field"
how I solve this error?
in json file

MoviesStudi
Автор

JSONArray empList = (JSONArray) obj; This Line is throwing run time exception

mrbrave
Автор

Hello sir...i am getting error..Unexpected character () at position 0.

Please help

iampranta_r
Автор

oh my web api result is [{ "emp1": "name1", "emp2":"name2"}]. i dont know how to parse this.

mr.RAND
Автор

How can i access a json object inside a json object?

likithaguntha
Автор

Hi, the video is helpful, but I'm getting below error, please look into this and let me know how to fix it:



Error: Unable to initialize main class jsonFiles.ReadingJsonFile
Caused by:




I'm using the same code as mentioned by you and have json simple jar as well.

anuradhatarekar