Skip to content

Kajol1906/JSON-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Parser Library

A powerful and scalable JSON parsing library built in Java, created to efficiently manage both basic and advanced JSON operations. Along with standard parsing, this project includes additional capabilities such as querying, validation, diff analysis, streaming-based processing, and indexed lookups for optimized performance.

Overview Advanced Query System: Access deeply nested JSON data using JSONPath-style expressions through JsonQuery. Schema Validation Engine: Verify JSON structure and value types with JsonValidator to maintain data consistency. JSON Difference Analyzer: Identify and visualize differences between JSON documents using JsonDiff. Streaming JSON Parser: Read and process large JSON files efficiently using the event-based JsonStreamParser without loading the entire file into memory. Indexed JSON Access: Retrieve values rapidly using path-based indexing with JsonIndexer. Comprehensive JSON Model: Supports all standard JSON data types including objects, arrays, strings, numbers, booleans, and null values through the JsonValue hierarchy. Modular Architecture: Organized package structure for parsing, querying, validation, diffing, streaming, and indexing, making the library maintainable and easy to extend.

Functionalities Parse JSON strings into Java object representations. Execute JSONPath-like queries on nested JSON data. Validate JSON content against custom-defined schemas. Compare JSON documents and generate detailed difference reports. Stream and process large JSON files with minimal memory usage. Perform fast path-based lookups through indexing.

Installation

Clone the repository:

git clone https://github.com/Kajol1906/JSON-Parser.git cd JSON-Parser

Compile the project files:

javac -d bin src/core/.java src/query/.java src/schema/.java src/diff/.java src/streaming/.java src/index/.java Usage Examples Parse JSON import core.Parser; import core.JsonValue;

String json = "{"name":"Kajol","age":20}";

Parser parser = new Parser(json); JsonValue value = parser.parse(); Execute Queries import query.JsonQuery;

JsonQuery query = new JsonQuery(value); JsonValue result = query.query("$.name"); Validate JSON Schema import schema.JsonValidator; import java.util.Map;

Map<String, Object> schema = Map.of( "name", "string", "age", "number" );

JsonValidator.validate(value, schema); Compare JSON Objects import diff.JsonDiff;

JsonDiff.DiffResult result = JsonDiff.diff(json1, json2);

System.out.println(result.toPrettyString()); Streaming Parser Example import streaming.JsonStreamParser; import streaming.PrintEventHandler; import java.io.FileReader;

JsonStreamParser parser = new JsonStreamParser( new FileReader("sample.json"), new PrintEventHandler(), null // No key filter applied );

parser.parse(); Indexed Lookup import index.JsonIndexer;

JsonIndexer indexer = new JsonIndexer(value);

JsonValue age = indexer.get("$.age"); Project Directory Structure src/core/ → Core parser and JSON model classes src/query/ → JSON query handling src/schema/ → Schema validation logic src/diff/ → JSON comparison utilities src/streaming/ → Streaming/event-driven parser src/index/ → JSON indexing implementation test/ → Unit testing files Running Unit Tests

Compile source and test files:

javac -d bin src/core/.java src/query/.java src/schema/.java src/diff/.java src/streaming/.java src/index/.java test/*.java

Run JUnit 5 tests:

java -cp bin org.junit.platform.console.ConsoleLauncher --scan-class-path

You can also execute tests directly using your preferred IDE.

License

This project is distributed under the MIT License.

Developer

Kajol Gehlot

Computer Science Engineering Student | Java Developer | Backend & AI/ML Enthusiast

GitHub: https://github.com/Kajol1906 LinkedIn: https://www.linkedin.com/in/kajol-gehlot-8352b12b8/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages