json util READMEThis VSCode extension provides an efficient way to validate, format, and generate Java model classes from JSON input. It simplifies the workflow for developers dealing with JSON data and Java projects by ensuring the JSON structure is valid and converting it into clean, well-structured Java classes. @author Suresh Nettur FeaturesJSON Validation: Automatically checks the given JSON input for syntax errors and highlights any issues, ensuring that your JSON is valid. JSON Formatting: Once the JSON is validated, the extension provides a neatly formatted version of the JSON for better readability and usability. Java Model Class Generation: If the JSON validation passes, the extension generates corresponding Java model classes based on the structure of the JSON. This includes fields, getters, setters, and support for nested objects and arrays. RequirementsTo use the JSON Validator and Java Model Class Generator extension, ensure you have the following prerequisites installed: Visual Studio Code: This extension runs inside VSCode, so make sure you have it installed. You can download it from https://code.visualstudio.com/. Node.js: The extension relies on Node.js for certain operations, such as JSON parsing and formatting. You can download Node.js from https://nodejs.org/. Java Development Kit (JDK): If you plan to generate Java model classes, you should have a working JDK installed on your system. The generated classes will be in plain Java, but the JDK helps with testing and further development. You can download the JDK from https://www.oracle.com/java/technologies/javase-downloads.html. InstallationDownload and install the extension from the Visual Studio Code Marketplace. Open Visual Studio Code. Go to the Extensions View (Ctrl+Shift+X or Cmd+Shift+X on Mac). Search for "JSON Validator and Java Model Class Generator". Click Install to add the extension to your workspace. Once installed, open any .json file, and the extension will automatically validate and format the JSON. Use the command palette (Ctrl+Shift+P or Cmd+Shift+P on Mac) to run the commands for validation, formatting, and Java class generation. UsageValidate JSON: Simply paste or type your JSON input, and click Process button, the extension will immediately validate it. Format JSON: Once validated, the extension will display the formatted version of the JSON for easy reading or shows errors where to fix.. Generate Java Classes: If all validations pass, the extension generates Java model classes that match the structure of the JSON, supporting both primitive types and nested objects. Input JSON: { "name": "John Doe", "age": 30, "address": { "city": "New York", "zipcode": "10001" }, "skills": ["Java", "TypeScript"] } Input Class Name: Person Generated Java Class: import java.util.List public class Person { private String name; private int age; private Address address; private List skills;
} public class Address { private String city; private String zipcode;
} with Lombok: import lombok.Data; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; /* Make sure to include lombok library in classpath or in pom.xml for maven projects, Example: org.projectlombok lombok */ @Data @AllArgsConstructor @NoArgsConstructor public class Address { private String city; private String zipcode; } import java.util.List; import lombok.Data; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Person { private String name; private int age; private Address address; private List skills; } Known IssuesHandling of highly complex nested JSON structures may result in deeply nested Java classes, which might require further optimization in future versions. Currently, only basic Java class structure (fields, getters, and setters) is supported. Advanced Java features (such as constructors or annotations) will be considered in future updates. Release Notes1.0.0Initial Release This is the first release of the JSON Validator and Java Model Class Generator extension for Visual Studio Code. The following features are included in the initial release: Features JSON Validation: Automatically validates the provided JSON input and highlights syntax errors in real-time. Formatted JSON Output: Upon successful validation, the extension formats the JSON input for better readability. Java Model Class Generation: Generates Java model classes from the given JSON structure.
1.0.1Backward compatability 1.1.0Added Lombok code generation. Added required imports. 1.2.0 (Future Version)Planned improvements might include: Support for custom constructors in generated Java classes. More configurable options for formatting, annotations, or additional language support. |