JSON 파일 불러오기
전자상거래 분석팀에 새로 합류하셨고, 첫 업무는 회사의 상품 카탈로그를 탐색하는 일이에요. 데이터는 JSON 파일로 제공되며, 이는 웹 API와 최신 데이터 소스에서 자주 접하게 되는 형식이에요.
분석을 시작하기 전에 JSON 데이터를 불러오고 구조를 파악해야 해요. JsonReader, JsonReadOptions, Table 클래스는 이미 가져와 두었어요.
이 연습은 강의의 일부입니다
Java에서 데이터 가져오기
연습 안내
- 파일에 대한 JSON 읽기 옵션을 구성하고 빌드하세요.
JsonReader를 생성하고 데이터를 테이블로 불러오세요.- 테이블의 처음 세 행을 표시하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
public class UnderstandingJSON {
public static void main(String[] args) {
// Configure and build JSON read options
JsonReadOptions options = ____.builder("products.json").____();
// Create JsonReader and load data
Table products = new ____().read(____);
System.out.println("Product Catalog Structure:");
System.out.println("Columns: " + products.columnNames());
System.out.println("Row count: " + products.rowCount());
System.out.println("\nTable structure:");
System.out.println(products.structure());
// Display first three rows
System.out.println("\nFirst few rows:");
System.out.println(products.____(3));
}
}