I am sure that this question has been asked before, but I do need help because I am nerd in the java programming (I am really very beginner). I use Netbeans as an IDE. Problem with the JSON file, I want to parse it but don't know how to do it in java.
Here's my JSON file looks like:
[
{
"rows":[
{
"positionId":1,
"userName":"Abay Nurpeissov/ Абай Нурпеисов",
"vacation":"",
"position":"Student",
"officePhone":"",
"mobilePhone":"",
"email":"",
"userid":"201641686",
"groupEmail":"",
"departmentPathEN":""
},
{
"positionId":1,
"userName":"Abilmansur Yeshmuratov/ Абильмансур Ешмуратов",
"vacation":"",
"position":"Student",
"officePhone":"",
"mobilePhone":"",
"email":"",
"userid":"201551882",
"groupEmail":"",
"departmentPathEN":""
}
]
}
]
And here's my code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package kyzdarkz;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.poi.hssf.usermodel.HSSFSheet;
/**
*
* @author anuar
*/
public class Kyzdarkz {
//private ArrayList<Student> students = new ArrayList();
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
try(BufferedReader br = new BufferedReader(new FileReader("json.txt"))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
String everything = sb.toString();
}
}
}
I want to save "userName" and "userid" as an array of vars. How can I do that?