Skip to content

Latest commit

 

History

History
46 lines (27 loc) · 3.04 KB

README.md

File metadata and controls

46 lines (27 loc) · 3.04 KB

JSON Iterator Build

JSON Iterator is a minimal adaption of the stream parsing features from the project json-iterator/java.

Functionality has been extended with inversion-of-control mechanics to help minimize object creation.

Parsing supports String, byte[], char[] and InputStream data sources.

Basic Usage

See JsonIterator.java for the public interface.

var jsonIterator = JsonIterator.parse("{\"hello\": \"world\"}");
System.out.println(jsonIterator.readObjField() + ' ' + jsonIterator.readString());

Recommended Usage

If the presence and ordering of the JSON object fields are guaranteed to always be the same, follow the StaticFieldOrdering style and simply skip over object field entries.

Otherwise, follow the IocLoopCompareStringFieldToCharsIf style, which enables inversion of control while it iterates over object fields in conjunction with comparing expected field strings against a field character array. The advantage of this strategy is that it avoids constructing Strings for object fields.

If the first character for all of an objects' fields are unique, follow either the IocLoopCharIf or IocLoopCharSwitch style. Similar to the style IocLoopCompareStringFieldToCharsIf, these styles avoid constructing Strings for object fields.

Style Comparison Benchmarks

String Fields

> ./gradlew jmh -Pbench=BenchStringFieldStyles

Each iteration parses a large json object (exchangeInfo.json). The results can also be viewed on JMH Visualizer.

String Fields Style Comparision

Char Fields

> ./gradlew jmh -Pbench=BenchCharFieldStyles

Each iteration parses a large json object (compactFieldsExchangeInfo.json). The results can also be viewed on JMH Visualizer.

Char Fields Style Comparision