Turns a JSON structure into a python object.
5150
def parse(binary, **params):
    """"""
    encoding = params.get('charset', 'UTF-8')
    return json.loads(binary, encoding=encoding)
388169
def _encode_json(obj):
    '''
    
    '''
    def _dump_obj(obj):
        if isinstance(obj, dict):
            return obj
        d = dict()
        for k in dir(obj):
            if not k.startswith('_'):
                d[k] = getattr(obj, k)
        return d
    return json.dumps(obj, default=_dump_obj)
911025
def from_json(cls, obj):
        
        if len(obj) == 2:
            (field, operator) = obj
            return cls(field, operator)
        if len(obj) > 2:
            (field, operator, value) = obj
            return cls(field, operator, value)
908516
def to_python(self, value):
        
        if not value:
            return {}
        elif isinstance(value, six.string_types):
            res = loads(value)
            assert isinstance(res, dict)
            return JSONDict(**res)
        else:
            return value
749228
def from_json(cls, json_dump):
        
        context = cls()
        if json_dump is None:
            return None
        ctxt = json.loads(json_dump)
        for k in ctxt:
            context[k] = ctxt[k]
        return context
867970
def from_json(cls, json):
        """"""
        obj = cls(name=json['name'],
                  code=json['code'],
                  numeric_code=json['numeric_code'],
                  symbol=json['symbol'],
                  exponent=json['exponent'],
                  entities=json['entities'],
                  withdrawal_date=json['withdrawal_date'],
                  subunits=json['subunits'])
        return obj
140420
def from_json_file(cls, json_file):
        """"""
        with open(json_file, "r", encoding="utf-8") as reader:
            text = reader.read()
        return cls.from_dict(json.loads(text))
469298
def fromJSON(value):
        
        j = json.loads(value)
        v = GPLinearUnit()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
955070
def to_python(self, value):
        
        if isinstance(value, dict):
            return value

        if self.blank and not value:
            return None

        if isinstance(value, string_types):
            try:
                return json.loads(value)
            except Exception as e:
                raise ValidationError(str(e))

        return value
142598
def dict_jsonify(param):
    """"""
    if not isinstance(param, dict):
        param = dict(param)
    return jsonify(param)
1163968
def from_json(s):
    
    d = json.loads(s)
    sbp = SBP.from_json_dict(d)
    return sbp
181595
def _parse_json(s):
    '  '

    def _obj_hook(pairs):
        ' convert json object to python object '
        o = JsonDict()
        for k, v in pairs.iteritems():
            o[str(k)] = v
        return o
    return json.loads(s, object_hook=_obj_hook)
7442
def __obj2json(self, obj):
        
        return json.dumps(obj, indent=self._indent, sort_keys=self._sort_keys)
561477
def _coerce_json_to_collection(self, json_repr):
        """"""
        if isinstance(json_repr, dict):
            collection = json_repr
        else:
            try:
                collection = anyjson.loads(json_repr)
            except:
                _LOG.warn('> invalid JSON (failed anyjson parsing)')
                return None
        return collection
218495
def _convert_dict_to_json(array):
    
    return json.dumps(
        array,
        skipkeys=False,
        allow_nan=False,
        indent=None,
        separators=(",", ":"),
        sort_keys=True,
        default=lambda o: o.__dict__,
    )
234239
def json_repr(obj):
    

    def serialize(obj):
        """Recursively walk object's hierarchy.
        """
        if obj is None:
            return None
        if isinstance(obj, Enum):
            return str(obj)
        if isinstance(obj, (bool, int, float, str)):
            return obj
        if isinstance(obj, dict):
            obj = obj.copy()
            for key in sorted(obj.keys()):
                obj[key] = serialize(obj[key])
            return obj
        if isinstance(obj, list):
            return [serialize(item) for item in obj]
        if isinstance(obj, tuple):
            return tuple(serialize([item for item in obj]))
        if hasattr(obj, '__dict__'):
            return serialize(obj.__dict__)
        return repr(obj)

    return json.dumps(serialize(obj))
1065944
def _process_json(self, item, parent=None):
        
        if "data" in item:
            return [self._process_json(i, parent) for i in item["data"]]

        result = {}
        for key, value in item.items():
            if isinstance(value, dict) and ("type" in value or "data" in value):
                value = self._process_json(value, parent)
            result[key] = value
        if parent is not None and hasattr(parent, "type"):
            result[parent.type] = parent

        if "type" in result:
            object_class = self.objects_types.get(result["type"], Resource)
        else:
            object_class = self.objects_types.get(parent, Resource)
        return object_class(self, result)