Convert The Output Of Openssl Command To Json
The output of the openssl command looks like this: serial=CABCSDUMMY4A168847703FGH notAfter=Oct 21 16:43:47 2024 GMT subject= /C=US/ST=WA/L=Seattle/O=MyCo/OU=TME/CN=MyCo.example.co
Solution 1:
You can split every line with "=" as a separator, put the two parts in an ordered dictionary and then dump it to json:
my_list = "serial=CABCSDUMMY4A168847703FGH".split("=")
ordered_dict = OrderedDict()
ordered_dict[my_list[0]] = my_list[1]
print(json.dumps(ordered_dict))
the output would be like this:
{"serial":"CABCSDUMMY4A168847703FGH"}
you can do it for all lines. PS don't forget to import json and OrderedDict
Post a Comment for "Convert The Output Of Openssl Command To Json"