docchangerpkg/jsonimport

Search:
Group by:

JSON import module

Handles parsing json and binding it to the Replacement object.

Consts

jsonExampleFileContent: string = "{\n    \"document_output_directory\": \"./path/to/output/directory/\",\n    \"document_source_filename\": \"example-document.docx\",\n\n    \"document_date_range\": {\n        \"starting\": \"yyyy-MM-dd\",\n        \"ending\": \"yyyy-MM-dd\",\n        \"starting_weekday\": 0,\n        \"day_interval\": 7\n    },\n\n    \"participants\": {\n        \"FEMALE\": [\n            \"insert\", \"names\"\n        ],\n        \"MALE\": [\n            \"in\"\n        ],\n        \"DIVERSE\": [\n            \"these\"\n        ],\n        \"INTERN\": [\n            \"quotes\"\n        ]\n    },\n\n    \"name_separator\": \", \",\n\n    \"search_strings\": {\n        \"starting\": \"${\",\n        \"participants_prefix\": \"PARTICIPANTS_\",\n        \"date\": \"INSERT_DATE\",\n        \"ending\": \"}\"\n    }\n}\n"
Compile-time json template reading (used for making a template, if no json was found, so the user does not have to painstakingly copy paste it from github)
jsonFile {.strdefine.}: string = "document_data.json"
Semi-hardcoded json filename

Procs

proc parseJsonToReplacement() {....raises: [TimeTravelError, JsonFileNotFoundError,
    JsonParsingError, JsonFormatError, OSError, ValueError, IOError], tags: [
    ReadIOEffect, WriteIOEffect, ReadDirEffect, RootEffect, TimeEffect],
                                forbids: [].}
Parses the json file and writes to the global replacement object