From e8788272eda9c2ab74fa6ee1a2cc260ed7e87e76 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Wed, 26 Feb 2025 15:23:47 +0000 Subject: add function to read json input --- gdpr_obfuscator/utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gdpr_obfuscator/utils.py b/gdpr_obfuscator/utils.py index 9736d7c..656b084 100644 --- a/gdpr_obfuscator/utils.py +++ b/gdpr_obfuscator/utils.py @@ -2,11 +2,20 @@ import csv import io from enum import Enum from typing import List, Dict +import json class Utilities: - def __init__(self, logger=None): - pass + + def process_json_input(json_input: str): + data = json.loads(json_input) + + if not data.get("file_path") or not data.get("pii_fields"): + raise ValueError( + "Missing required file_path & pii_fields entries in JSON input" + ) + + return data["file_path"], data["pii_fields"] @staticmethod def get_s3_path(uri): -- cgit v1.2.3