A Java library for parsing, validating, and manipulating JSON data with strong type safety and customizable object structures.
- JSON Validation: Strict validation according to JSON specification
- Type Safety: Strong type checking and conversion
- Custom Object Mapping: Convert JSON to typed Java objects
- Duplicate Key Detection: Validation for unique keys within objects
- Pretty Printing: Configurable JSON string formatting
- Unicode Support: Full support for Unicode characters and escape sequences
Add this dependency to your pom.xml
:
<dependency>
<groupId>com.github.stevenlagoy</groupId>
<artifactId>json-java-objectifier</artifactId>
<version>1.0.0</version>
</dependency>
From Java String:
String jsonString = "{\"key\":\"value\"}";
JSONObject obj = JSONProcessor.processJson("root", jsonString);
From JSON File:
Path jsonPath = Path.of("path", "to", "file.json");
JSONObject obj = JSONProcessor.processJson(jsonPath);
From Java String:
String jsonString = "{\"numbers\":[1,2,3]}";
boolean isValid = JSONValidator.validateJson(jsonString);
From JSON File:
Path jsonPath = Path.of("path", "to", "file.json");
JSONObject obj = JSONValidator.validateJson(jsonPath);
JSONObject obj = new JSONObject("key", "value");
String str = obj.getAsString(); // Type-safe string access
Number num = obj.getAsNumber(); // Type-safe number access
Boolean bool = obj.getAsBoolean(); // Type-safe boolean access
List<?> list = obj.getAsList(); // Type-safe list access
With JSONObject.toString():
JSONObject obj = JSONProcessor.processJson("root", jsonString);
String formatted = obj.toString(); // Returns formatted JSON string
With JSONStringifier:
JSONObject obj = JSONProcessor.processJson("root", jsonString);
String formatted = JSONStringifier.stringifyJson(obj); // Returns formatted JSON string on one line
- Strings (with Unicode)
- Numbers (Integer, Long, Double)
- Objects (nested)
- Arrays
- Booleans
- Null values
- Strict JSON syntax checking (ECMA-404 specification)
- Duplicate key detection
- Type validation
- Unicode escape sequence validation
- Detailed error messages
- Type conversion safety
- Null safety
git clone https://github.com/stevenlagoy/json-java-objectifier.git
cd json-java-objectifier
mvn clean install
- Java 21 or higher
- Maven 3.x
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Java 21
- Uses JUnit for testing
- SpotBugs for code quality
- Maven for build management