json 객체에서 키를 가져오고 싶습니다. 나는 그것을 얻기 위해 아래의 코드를 사용하고이 부분에서 자바에서 JSONObject에서 키를 가져올 수 없습니다.
JSONParser parser = new JSONParser();
try {
Object obj = null;
try {
obj = parser.parse(new FileReader(new File("json/customer_list.json")));
} catch (org.json.simple.parser.ParseException e1) {
e1.printStackTrace();
}
JSONObject jsonObject = (JSONObject) obj;
JSONArray listOfBranches = (JSONArray) jsonObject.get("customers");
for (int i = 0; i < listOfBranches.size(); i++) {
System.out.println("Customer :" + listOfBranches.get(i));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
,
에서 System.out.println ("고객 :"+ listOfBranches.get (I)); 나는 아래의 객체를 얻고있다
, 내가 사진, 비디오 및 도면 키를 얻으려면이 JSON에서
{"Photo":{"input_required":false,"output_type":"","input_fields":[{"input_type":"INTEGER","length":"","reg_exp":"","label":"","field_type":"TEXT"},{"values":"","length":"","reg_exp":"","label":"Mode","field_type":"drop_down"},{"length":"","input_type":"INTEGER","reg_exp":"","label":"Quantity","field_type":"TEXT"}]},"video":{"input_required":true,"output_type":"","input_pattern":""},"drawing":{"input_required":true,"output_type":"PDF","input_pattern":""}}
. 이 일을 할 생각을 나에게 제안 해 주시겠습니까? 미리 감사드립니다.
일반적으로 당신이'출력 [ "사진"]'같은 것을 사용하여 JSON 값을 얻을 수 있습니다, 하지만 자바에서 작동하는지 모르겠습니다. 'listOfBranches.get ("Photo")'는 작동합니까? – numbermaniac