1

i want to read certain data from a config file as key,value

i found below way to define the key value in config.ini

[Section]
value={"name":"John","id":"101"}

but not seeing the way to parse this value as dictionary in python i actually need to retrieve each key value from 'Section value'

Any right solution to this?

Adhi cloud
  • 39
  • 6

1 Answers1

2

You can read the value as usual string then parse it with json package

import configparser
import json

config = configparser.ConfigParser()
config.read('config.ini')
string = config['Section']['value']
obj = json.loads(string)
ytung-dev
  • 872
  • 1
  • 2
  • 12