i am reading .csr file in a variable which keeps its format as is, so when i print variable it prints just like its stored in a file.
when i assign this to a key in dictionary i see '
' visible in it.
how can i keep the format of a text variable intake while converting to json.
ex.
import json
if __name__ == "__main__":
# python3 test.py --appenv = 'dev' --certtype = 'add' --certpath = '/etc/ssl/certs/mssql.cer' --uname = test --pass = test
a = '''-----BEGIN CERTIFICATE-----
MIIHyDCCBbCgAwIBAgITRQAeiysRV+gPdQpj/gABAB6LKzANBgkqhkiG9w0BAQsF
ADBbMRMwEQYKCZImiZPyLGQBGRYDbmV0MRgwFgYKCZImiZPyLGQBGRYIanBtY2hh
c2UxFjAUBgoJkiaJk/IsZAEZFgZleGNoYWQxEjAQBgNVBAMTCVBTSU4wUDU1MTAe'''
print(a)
checkbody = {
"action" : 'args.certtype',
"fsid" : 'args.uname',
"thumbprint" : 'thumbprint', # if renewing.
"csr" : a, # read and pt csr here.
"certType" : "Internal Facing only for Mutual and/or Server Authentication",
"noOfLicenses" : "1"
}
print(type(checkbody))
print(json.dumps(checkbody))
When i run this it adding
to it. i need to keep the format of a string.
see output below.
-----BEGIN CERTIFICATE-----
MIIHyDCCBbCgAwIBAgITRQAeiysRV+gPdQpj/gABAB6LKzANBgkqhkiG9w0BAQsF
ADBbMRMwEQYKCZImiZPyLGQBGRYDbmV0MRgwFgYKCZImiZPyLGQBGRYIanBtY2hh
c2UxFjAUBgoJkiaJk/IsZAEZFgZleGNoYWQxEjAQBgNVBAMTCVBTSU4wUDU1MTAe
<class 'dict'>
{"action": "args.certtype", "fsid": "args.uname", "thumbprint": "thumbprint", "csr": "-----BEGIN CERTIFICATE-----
MIIHyDCCBbCgAwIBAgITRQAeiysRV+gPdQpj/gABAB6LKzANBgkqhkiG9w0BAQsF
ADBbMRMwEQYKCZImiZPyLGQBGRYDbmV0MRgwFgYKCZImiZPyLGQBGRYIanBtY2hh
c2UxFjAUBgoJkiaJk/IsZAEZFgZleGNoYWQxEjAQBgNVBAMTCVBTSU4wUDU1MTAe", "certType": "Internal Facing only for Mutual and/or Server Authentication", "noOfLicenses": "1"}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…