Skip to content

AlexiyOrlov/json-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

JSON tools

A small library for working with JSON5 data. Currently includes a parser, which converts the data to a List or a Map, and a serializer, which converts a Map or a List to JSON5 data. The parser and serializer have been adapted from the original JavaScript functions.

Requirements

This library requires Java 9+.

Usage

Parsing

String json5Data = Functions.readJson(Paths.get("path", "to", "file"));
Json5Parser json5Parser = new Json5Parser(json5Data);
Object result = json5Parser.parse();
//or if you know the input type:
List<Object> list=json5Parser.parseAsList();
Map<String,Object> map=json5Parser.parseAsMap();

Serializing

List<?> list=...;
Json5Serializer serializer=new Json5Serializer(list);
String result=serializer.serialize();
Map<?,?> map=...;
//set the indent size to 6
Json5Serializer mapSer=new Json5Serializer(map,6);
String result2=mapSer.serialize();

Maven Central

About

Simple parsing and serialization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published