Package io.github.jbastgen.stemma.app.ai
Class Json
java.lang.Object
io.github.jbastgen.stemma.app.ai.Json
A small JSON reader and writer, enough for the requests and answers of AI services: objects become
Map<String,Object>, arrays List<Object>, numbers Double, plus String, Boolean
and null. No dependency, and strict about what it reads.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe text is not valid JSON. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectReads JSON into maps, lists, strings, doubles, booleans andnull; anything after the value is an error.static ObjectThe value at a path of keys and indexes separated by dots, for examplechoices.0.message.content; ornullif there is none.static StringThe JSON string literal fors, with the quotes.static StringWrites a value built from maps, lists, strings, numbers, booleans and null.
-
Method Details
-
parse
Reads JSON into maps, lists, strings, doubles, booleans andnull; anything after the value is an error.- Throws:
Json.JsonException- when the text is not valid JSON
-
quote
The JSON string literal fors, with the quotes. -
write
Writes a value built from maps, lists, strings, numbers, booleans and null. -
path
The value at a path of keys and indexes separated by dots, for examplechoices.0.message.content; ornullif there is none.
-