GitHub - LupCode/java-json: Robust and efficient JSON parser and generator that includes line and column tracker for error handling. Can handle strings as well as streams for parsing and generating. · GitHub
Skip to content

LupCode/java-json

Folders and files

Repository files navigation

Java JSON API

Robust and efficient JSON parser and generator that includes line and column tracker for error handling.
Can handle strings as well as streams for parsing and generating.

Requires:

How to use:

String jsonStr = "{\"Hello World\":[{\"Test\":1.2,\"Bye\":null},345,]}";
		
// Automatically detects class needed to parse JSON
JSON<?> autoJson = JSON.parseAutoJSON(jsonStr);
System.out.println(autoJson.toString(true));

// Another example that shows how errors in the JSON data can be handled
try {
	JsonObject jsonObj = JsonObject.parse(jsonStr);
	System.out.println(jsonObj.toString());
} catch(JsonParseException ex) {
	LineColumnTracker lct = ex.getLineColumn();
	if(lct != null)
		System.out.println("Error occurred at line "+lct.getLine()+", column "+lct.getColumn());
	else
		ex.printStackTrace();
}

References:

About

Robust and efficient JSON parser and generator that includes line and column tracker for error handling. Can handle strings as well as streams for parsing and generating.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages