Why can't Python parse this JSON data?

后端 未结 9 2476
傲寒
傲寒 2020-11-21 05:06

I have this JSON in a file:

{
    \"maps\": [
        {
            \"id\": \"blabla\",
            \"iscategorical\         


        
9条回答
  •  情歌与酒
    2020-11-21 05:24

    If you're using Python3, you can try changing your (connection.json file) JSON to:

    {
      "connection1": {
        "DSN": "con1",
        "UID": "abc",
        "PWD": "1234",
        "connection_string_python":"test1"
      }
      ,
      "connection2": {
        "DSN": "con2",
        "UID": "def",
        "PWD": "1234"
      }
    }
    

    Then using the following code:

    connection_file = open('connection.json', 'r')
    conn_string = json.load(connection_file)
    conn_string['connection1']['connection_string_python'])
    connection_file.close()
    >>> test1
    

提交回复
热议问题