"""Helper library for Robot Framework to load JSON files.""" import json def parse_json(json_string): """Parse a JSON string and return as a dictionary.""" return json.loads(json_string) class JsonHelper: """Helper class for loading and processing JSON files.""" @staticmethod def load_json_file(file_path): """Load JSON from a file and return as a dictionary.""" with open(file_path) as f: return json.load(f) @staticmethod def get_dict_keys(data, key): """Get keys from a nested dictionary.""" if key in data: return list(data[key].keys()) return [] @staticmethod def get_nested_value(data, *keys): """Get a value from nested dictionary using a path of keys.""" result = data for key in keys: if isinstance(result, dict): result = result.get(key) else: return None return result