1. Learn
  2. /
  3. Courses
  4. /
  5. Importing Data in Java

Connected

Exercise

JSON validation

Your product analysis is working well, and the team wants to deploy it as an automated daily report. But in production, JSON files might be missing, corrupted, or arrive in unexpected formats. Before going live, you need to add error handling so the application fails gracefully.

The JsonReader, JsonReadOptions, and Table classes have been imported for you.

Instructions

100 XP
  • Add a try block to wrap the JSON loading code.
  • Add a catch block to handle any exceptions.
  • Print the error message if loading fails.