Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

if dict json

class LoadInfo(object):
    def load_from_file(self, file):
        with open(file) as f:
            data = f.read()
        self.config = json.loads(data)

    def load_from_str(self, info):
        if isinstance(info, dict):
           self.config = info
        elif isinstance(info, str):
            self.config = json.loads(info)
        else:
            raise ValueError('Load config error')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dict #json
ADD COMMENT
Topic
Name
1+7 =