I am new to JSON and Java ,using following code ,I am trying to read JSON data from text file but its not showing result for multiple value data
Anyone Please help me ,Let me know where I am wrong
JSONParser parser = new JSONParser();
try {
Object obj = parser.parse(new FileReader("C:/Users/Desktop/file.json"));
JSONObject jsonObject = (JSONObject) obj;
String K1= (String) jsonObject.get("V1");
String K2= (String) jsonObject.get("V2");
System.out.println(V1);
System.out.println(V2);
JSONArray K3= (JSONArray) jsonObject.get("K3");
for (Object c : K3)
{
System.out.println(c+"");
}
} catch ( Exception e){
e.printStackTrace();
}
}
}
File.json
{"K1":"V1" ,"K2":"V2" ,"K3" : "V3.1 ,V3.2"}
CURRENT Output : V1 V2
Expected output V1 V2 V3.1 V3.2
any pls tell me where I am wrong