I'm trying to map a json file to a python object based on this solution.
The code I tried to write is the following:
from json import loads
from collections import namedtuple
from os import path
class CamConfigurator:
with open(path.join('utility', 'cam', 'configurator.json')) as __configFile:
__configurator = loads(
__configFile,
object_hook=lambda dictonary: namedtuple(
'X', dictonary.keys()
)(*dictonary.values())
)
camIndex = __configurator.availableCams[-1]
pathToSnapshots = __configurator.pathToSnapshots
The error that came out is the following:
TypeError: expected string or buffer