I am trying to get a string that is the following format converted to a dictionary. it is in the from of a json but it is, by type, one continuous string. My goal is to turn it into a list of dictionaries. I have tried using split but that ADDS [] when it already has them. this variable is NOT in a json file and will always initially be a string in the script it exists in. I use a function to get it into a variable as a string. from there I need to make it a list of dictionaries.
The large amount of quotes are unimportant as a previous answer informed me that 'abc''def' in python is the same as 'abcdef'. the "" ARE a part of the data so "title" and all other words with "" around them will retain those quotes.
'['
'{'
' "title": { "text": "Test Title" }, '
' "axisX": {'
' "title": "Time", '
' "valueFormatString": "hh:mm:ss.sss", '
' "nMajTicks": "11", '
' "nMinTicks": "0", '
' "minimum": "0", '
' "maximum": "10" '
' }'
'}'
']'
I was wondering if there is a library function for this in python or if im going to have to iterate thru the string and look for specific characters to create key item pairs. Thank you!
'abc' 'def'
as'abcdef'
. What you have above is just a single string with no newlines. - Frank Yellin'
characters literally in the data, or is this just how you wrote it as a Python literal? - Barmarjson.loads()
will convert a JSON string to a Python object. - Mark Tolonen