Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I convert a string of a python dictionary to JSON object? json.loads() gives me a double quote error every time

I have this as a string:

{{
            "intent": "catalog_search",
            "id": 1,
            "dependency": [],
            "args": {{
                "text": "Could you please retrieve all table assets scanned before 1 hour?"
            }}
        }}

When I apply json.loads() to it, I get the error "json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)". What gives? All of the keys clearly have double quotes, is my formatting wrong in some way?

I thought the issue might be the double curly brackets at the start and end, but I got the same result when I removed them.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

All the double braces need to be changed to single braces. This is valid:

{
    "intent": "catalog_search",
    "id": 1,
    "dependency": [],
    "args": {
        "text": "Could you please retrieve all table assets scanned before 1 hour?"
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading