Skip to content
CCPEDIAby Unity Nodes
App Development

Can Canton configuration files be in JSON format?

3 posts124 views2 likesLast activity May 2024

  1. WallaceKellyOP

    The typical Canton example has the configuration files in HOCON format. That is really nice for human readability and editability.

    Does Canton also accept configuration files in JSON format?

  2. WallaceKelly 1

    Apparently so. I converted a HOCON configuration file into a JSON file using this CLI tool.

    HOCON Example
    canton {
      participants {
        mynode {
          ledger-api.address=localhost
        }
      }
    }
    
    Equivalent JSON
    hoconvert --file canton.conf --output json > canton.json
    
    {
      "canton": {
        "participants": {
          "mynode": {
            "ledger-api": {
              "address": "localhost"
            }
          }
        }
      }
    }
    

    Canton accepted both HOCON and JSON files without error:

    docker run -it --rm \
      --volume ./:/host/ \
      digitalasset/canton-open-source:2.7.9 \
      --config /host/canton.conf
    
    participants.local.head.health.status
    
    docker run -it --rm \
      --volume ./:/host/ \
      digitalasset/canton-open-source:2.7.9 \
      --config /host/canton.json
    
    participants.local.head.health.status
    

    This could be helpful for script-based creation and editing of configuration files. There is simply more JSON-aware tooling available (e.g., jq).

  3. Gary_Verhaegen 1

    It is a property of HOCON that any valid JSON file is also a valid HOCON file.