
import json

from .utils_debug import debug_err


try:
    from types import SimpleNamespace as Namespace
except ImportError:
    # Python 2.x fallback
    from argparse import Namespace


def jsonStringToObject(data):
    try:
        x = json.loads(data, object_hook=lambda d: Namespace(**d))
        return x
    except Exception as e:
        debug_err(e)
    return None