शुरू करेंमुफ़्त में शुरू करें

JSON फाइलें लोड करना

आप अभी-अभी एक ई-कॉमर्स एनालिटिक्स टीम में जुड़े हैं, और आपका पहला काम कंपनी के प्रोडक्ट कैटलॉग को खँगालना है. डेटा JSON फाइल के रूप में आया है — ऐसा फ़ॉर्मैट जो वेब API और आधुनिक डेटा सोर्स के साथ काम करते समय अक्सर मिलेगा.

विश्लेषण शुरू करने से पहले, आपको JSON डेटा लोड करना है और उसकी संरचना समझनी है. JsonReader, JsonReadOptions, और Table क्लास आपके लिए पहले से इम्पोर्ट कर दिए गए हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Java में डेटा इम्पोर्ट करना

पाठ्यक्रम देखें

अभ्यास निर्देश

  • फाइल के लिए JSON read options कॉन्फ़िगर करें और build करें.
  • एक 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));
    }
}
कोड संपादित करें और चलाएँ