Consider this very simple tibble
tibble(horrible_python_dict = "{\"Java\":1,\"Stata\":2,\"Texas Instrument\":13,\"Pearl\":900,\"GameBoy\":2}")
# A tibble: 1 x 1
horrible_python_dict
<chr>
1 "{\"Java\":1,\"Stata\":2,\"Texas Instrument\":13,\"Pearl\":900,\"GameBoy\":2}"
As you can see, my tibble contains a good-ol python dictionary encoded as a string!
How can I convert this horrible string to a nice looking R list-column? That is, the ideal output should be
tibble(better_list_col = list(list('Java' = 1,
'Stata' = 2,
'Texas Instrument' = 12,
'Pearl' = 900,
'GameBoy' = 2)))
# A tibble: 1 x 1
better_list_col
<list>
1 <list [5]>
Do I necessarily have to use some regex magic here or there is something simpler?
Thanks!