'Deserialize Object in String to Python Dict

I'm using apache solr and python, when I send data in the form a dict/obj it is stored and received as

{
  "array": [
    "{key: value}, {key: value}, {key: value}",
    "{key: value}, {key: value}, {key: value}",
    "{key: value}, {key: value}, {key: value}"
  ],
}

is it possible to convert that python string into a python dict

N.B the values I'm expecting are either string or float

Update: I decided to use the built-in JSON encoder to serialize each instance of a nested python dictionary and send that to the SOLR instance, finally when I'm retrieving the data I just deserialize the already encoded json string



Solution 1:[1]

I decided to use the built-in JSON encoder to serialize each instance of a nested python dictionary and send that to the SOLR instance, finally when I'm retrieving the data I just deserialize the already encoded json string

import json

{
  "array": [
    json.loads({key: value, key: value, key: value}),
  ],
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marc_s