Generation

generate functionWed, 12 Apr 2023

how to take first column of a json

import json def convert(input_data): if isinstance(input_data, dict): return {key: convert(value) for key, value in input_data.items()} elif isinstance(input_data, list): return [convert(element) for element in input_data] elif isinstance(input_data, str): return input_data.encode('ascii', 'ignore') else: return input_data raw_data = '{"1": "one", "2": "two", "3": "three"}' json_data = json.loads(raw_data) print(convert(json_data))

Questions about programming?Chat with your personal AI assistant