Skip to content

Java JSON Parser - parser and correct a JSON object according to a given JSON schema

License

Notifications You must be signed in to change notification settings

GDLMadushanka/JJParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JJParser

logo2

JJParser stands for JAVA JSON Parser which rectifies your JSON input according to a given schema.

  • Support JSON schema draft 07
  • Structure and data type correction
  • Written in Java
  • Only depended on Google gson

Sample usage

To demonstrate the functionality, let's choose a JSON input string which needs both data type and structural corrections.

    String schema = "{\n" +
                "  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n" +
                "  \"type\": \"object\",\n" +
                "  \"properties\": {\n" +
                "      \"singleObjArray\": {\n" +
                "          \"type\": \"array\",\n" +
                "          \"items\": [{\"type\": \"number\"}]\n" +
                "      }\n" +
                "  }\n" +
                "}";
    String inputJson = "{\"singleObjArray\":\"1.618\"}";
    String result = JavaJsonParser.parseJson(inputJson, schema);
    System.out.println(result);

Which will give the following corrected output

{"singleObjArray":[1.618]}

Development

Want to contribute? Great!

You can contribute by

  • Adding test cases.
  • Reporting issues.
  • Updating the project with latest schema changes.
  • Add currently unsupported properties like "instaceOf"

About

Java JSON Parser - parser and correct a JSON object according to a given JSON schema

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages