Deserialize a JSON file containing runtime collected types.

    The input JSON is expected to to have a list of RawEntry items.
194384
def parse_json(path):
    # type: (str) -> List[FunctionInfo]
    
    with open(path) as f:
        data = json.load(f)  # type: List[RawEntry]
    result = []

    def assert_type(value, typ):
        # type: (object, type) -> None
        assert isinstance(value, typ), '%s: Unexpected type %r' % (path, type(value).__name__)

    def assert_dict_item(dictionary, key, typ):
        # type: (Mapping[Any, Any], str, type) -> None
        assert key in dictionary, '%s: Missing dictionary key %r' % (path, key)
        value = dictionary[key]
        assert isinstance(value, typ), '%s: Unexpected type %r for key %r' % (
            path, type(value).__name__, key)

    assert_type(data, list)
    for item in data:
        assert_type(item, dict)
        assert_dict_item(item, 'path', Text)
        assert_dict_item(item, 'line', int)
        assert_dict_item(item, 'func_name', Text)
        assert_dict_item(item, 'type_comments', list)
        for comment in item['type_comments']:
            assert_type(comment, Text)
        assert_type(item['samples'], int)
        info = FunctionInfo(encode(item['path']),
                            item['line'],
                            encode(item['func_name']),
                            [encode(comment) for comment in item['type_comments']],
                            item['samples'])
        result.append(info)
    return result
427632
def from_json(self, json):
        
        res_type = json['sys']['type']

        if ResourceType.Array.value == res_type:
            return self.create_array(json)
        elif ResourceType.Entry.value == res_type:
            return self.create_entry(json)
        elif ResourceType.Asset.value == res_type:
            return ResourceFactory.create_asset(json)
        elif ResourceType.ContentType.value == res_type:
            return ResourceFactory.create_content_type(json)
        elif ResourceType.Space.value == res_type:
            return ResourceFactory.create_space(json)
22701
def __json(self):
        
        if self.exclude_list is None:
            self.exclude_list = []
        fields = {}
        for key, item in vars(self).items():
            if hasattr(self, '_sa_instance_state'):
                # load only deferred objects
                if len(orm.attributes.instance_state(self).unloaded) > 0:
                    mapper = inspect(self)
                    for column in mapper.attrs:
                        column.key
                        column.value
            if str(key).startswith('_') or key in self.exclude_list:
                continue
            fields[key] = item
        obj = Json.safe_object(fields)
        return str(obj)
146646
def deserialize(self, msg):
        ''
        self.logger.debug('deserializing %s', msg)
        return json.loads(msg)
525687
def deserialized_objects(self):
        
        if not self._deserialized_objects:
            json_text = self.read()
            self._deserialized_objects = self.deserialize(json_text=json_text)
        return self._deserialized_objects
406350
def deserialize(self, serialized):
        '''
        '''
        deserialized = json.loads(serialized)
        if deserialized.get('identifier') is None:
            return self._deserialize_v2(deserialized)
        else:
            return self._deserialize_v1(deserialized)
1334598
def _deserialize(self, value, environment=None):
        """"""

        if not isinstance(value, CollectionABC):
            raise exc.Invalid(self)

        items_class = self.items.__class__
        invalids = []

        # traverse items and match against validated struct
        collection = self.collection_type()

        for i, subvalue in enumerate(value):
            item = items_class(name=i)
            try:
                self.collection_pusher(collection, item.deserialize(subvalue, environment=environment))

            except exc.Invalid as ex:
                invalids.append(ex)

        if invalids:
            # on invalids this item is also ``Invalid``
            raise exc.InvalidChildren(self, invalids)

        return collection
728610
public static List<FormInput> deserializeFormInputs(File dir) {

		List<FormInput> deserialized = new ArrayList<>();
		final File in = new File(dir, FORMS_JSON_FILE);

		if (in.exists()) {
			LOGGER.info("Reading trained form inputs from " + in.getAbsolutePath());
			Gson gson = new GsonBuilder().create();

			try {
				deserialized =
						gson.fromJson(FileUtils.readFileToString(in, Charset.defaultCharset()),
								new TypeToken<List<FormInput>>() {
								}.getType());

			} catch (JsonSyntaxException | IOException e) {
				LOGGER.error(e.getMessage(), e);
			}
		}

		return deserialized;

	}
737477
def from_json(cls, s):
        
        d = json.loads(s)
        return get_dict_handler(d["type"])(d)
828199
def deserialize_instance(model, data={}):
    ""
    ret = model()
    for k, v in data.items():
        if v is not None:
            try:
                f = model._meta.get_field(k)
                if isinstance(f, DateTimeField):
                    v = dateparse.parse_datetime(v)
                elif isinstance(f, TimeField):
                    v = dateparse.parse_time(v)
                elif isinstance(f, DateField):
                    v = dateparse.parse_date(v)
            except FieldDoesNotExist:
                pass
        setattr(ret, k, v)
    return ret
49614
def load_json(json_list, into=None):
    
    def l2t(obj):
      if isinstance(obj, list):
        return tuple(l2t(L) for L in obj)
      elif isinstance(obj, dict):
        return frozendict(obj)
      else:
        return obj
    return TypeFactory.load(l2t(json_list), into=into)
1009878
def deserialize(self, data):
        
        if not data:
            return dict()
        return self._deserialize_datetime(pickle.loads(data))
1192388
public static <T> T deserialize(byte[] input, Class<T> classType)
            throws JsonParseException, JsonMappingException, IOException {
        return mapper.readValue(input, classType);
    }
898204
def _deserialize_datetime(self, data):
        
        for key in data:
            if isinstance(data[key], dict):
                if data[key].get('type') == 'datetime':
                    data[key] = \
                        datetime.datetime.fromtimestamp(data[key]['value'])
        return data
689816
def read_data_types(self):
        """"""
        return {
            'Binary': self.read_binary,
            'BinaryArray': self.read_binary_array,
            'KeyValue': self.read_key_value,
            'KeyValueArray': self.read_key_value_array,
            'String': self.read_string,
            'StringArray': self.read_string_array,
            'TCEntity': self.read_tc_entity,
            'TCEntityArray': self.read_tc_entity_array,
        }
1080076
def find_json(raw):
    '''
    
    '''
    ret = {}
    lines = __split(raw)
    for ind, _ in enumerate(lines):
        try:
            working = '\n'.join(lines[ind:])
        except UnicodeDecodeError:
            working = '\n'.join(salt.utils.data.decode(lines[ind:]))

        try:
            ret = json.loads(working)  # future lint: blacklisted-function
        except ValueError:
            continue
        if ret:
            return ret
    if not ret:
        # Not json, raise an error
        raise ValueError
154251
def from_raw(self, rval: RawList, jptr: JSONPointer = "") -> ArrayValue:
        """"""
        if not isinstance(rval, list):
            raise RawTypeError(jptr, "array")
        res = ArrayValue()
        i = 0
        for en in rval:
            i += 1
            res.append(self.entry_from_raw(en, f"{jptr}/{i}"))
        return res