classnetColarUtils::JsonSettings

sys::Obj
  netColarUtils::JsonSettings

JsonSettings

Allows for Easy, documented settings files

Settings will be saved in property file like file but with comments and values in Json format

All fields in the saved object with the Facet "Setting" will be saved (Json format) Fields with the Setting Facet can NOT be nullable. If a field has a default value it will be displayed as well (as a comment in saved file)

commentChar

Str commentChar := "#"

Line comment char (default: #)

consumeWs

Str consumeWs(InStream in)

consume white space, returns next (non-ws) char

headComments

Str[] headComments := ...

Comments to show at the top of the file commentChar will be prepanded to each line

load

static Obj? load(File file, Type type)

Load settings from a file into given type

make

new make(|This f)

read

Obj? read(Type type, InStream in)

Load the settings from a stream/file and inject them into a new object of given type the type must have an it constructor => new make(|This| f) {f(this)} Might throw an Err if parsing fails

readProp

Str readProp(InStream in)

save

Void save(Obj o, OutStream out)

Save the settings (complete overwrite) Closes the stream when done

update

Void update(Obj o, File f)

Try to save the file "in place" so that if use reordered or added comments we leave those alone. Will remove props that are no longer present and add new ones with default vals. If the file does not exist yet, then it just calls save()