JSON Config

Develop once, deploy everywhere

This compnent enables external configuration via a JSON-File. 
The definition of the config is done via en extensive Callback. To create the definition you need to return a dictionary containing Definition values. The possible values are passed as arguments to the GetConfigSchema callback.


LoadConfig( configStr: str = "" )
Forces the configComp to reload the contents.
It traverses several possibilitites:
  1. Check the configStr. If the configStr is a valid JsonString, it will be used.
  2. Check the GetConfigData Callback. Return data as a jsonString.
  3. Saved file on Disk.

After the Config is loaded, the data will be sanitized, validated and saved to the configFile!

Collection Value

    default: any = "",
    validator: callable[[any], any] = lambda value: True,
    parser: callable[[any], any] = lambda value: value,
    typecheck: type = object
  • default : The default value this CollectionValue obtains if the member is not present in the current config or the validation fails.
  • validator : A function taking the value and returning a boolean if the value is valid.
  • parser: takes the inputdata and returns the object parsed. i.E. for capitalising strings or making ints to floats.
  • typecheck : a single type or tuple of types to validate the type of the inputs.

Note: You can call any CollectionItem (Value, Dict, List) to create a copy of the item. This is needed if you want to reuse a component.
positiveValue = CollectionValue( default = 2, validator =lambda value: lambda > 0 )
return {
    "PositiveA" : positiveValue(),
    "PositiveB" : positiveValue() 


    items:dict = {}
  • items : A dictionary with a string key and either CollectionDict/Value/List


    items:list = [],
    default_member = CollectionItem
  • items: prefill the list with items.
  • default_member: CollectionItem (Value, Dict, List) that will be used as a validator/parser for all items.

To acces the members use the Data-Attribute. ColectionValues have Value and Dependency members. Use Value for explicit use of the value. 
op("json_config").Data.MyValue.Dependency #T bind to the value
op("json_config").Data.MyValue.Value #For explicit read-access to the value itself.

Use the "Save" method or Pulseparameter to writte bound values in to the config itself.

Under Windows use
setx [variable_name] "[variable_value]"
to permanently set the env-variable, or a simple 
set TD_ENV=variablevalue
before starting in a .bat file.

Downloads: 776

Created at: 6.2.2022

Uploaded: 2.2.2024
New main version.
- Added Enum
- Added NamedList
All members are now passed as single class to callback.
i.E. use configModule.ConfigValue