in Count/src/index.py [0:0]
def update_placeholder(resource_structure, iteration):
#Convert the json into a string
resourceString = json.dumps(resource_structure)
#Count the number of times the placeholder is found in the string
placeHolderCount = resourceString.count('%d')
#If the placeholder is found then replace it
if placeHolderCount > 0:
print("Found {} occurrences of decimal placeholder in JSON, replacing with iterator value {}".format(placeHolderCount, iteration))
#Make a list of the values that we will use to replace the decimal placeholders - the values will all be the same
placeHolderReplacementValues = [iteration] * placeHolderCount
#Replace the decimal placeholders using the list - the syntax below expands the list
resourceString = resourceString % (*placeHolderReplacementValues,)
#Convert the string back to json and return it
return json.loads(resourceString)
else:
print("No occurences of decimal placeholder found in JSON, therefore nothing will be replaced")
return resource_structure