Wrap ``JSONDeSerializable`` object in JWS.

        ..  todo:: Implement ``acmePath``.

        :param ~josepy.interfaces.JSONDeSerializable obj:
        :param bytes nonce:

        :rtype: `bytes`
        :return: JSON-encoded data
434365
def _wrap_in_jws(self, nonce, obj):
        
        with LOG_JWS_SIGN(key_type=self._key.typ, alg=self._alg.name,
                          nonce=nonce):
            jobj = obj.json_dumps().encode()
            return (
                JWS.sign(
                    payload=jobj, key=self._key, alg=self._alg, nonce=nonce)
                .json_dumps()
                .encode())
843518
public Serializable deserializeFromBytes(final byte[] bytes) {
        Serializable o = null;
        try (final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            final ObjectInputStream ois = new RestrictedObjectInputStream(bais, this.trustedPackages, this.trustedClasses)) {
            o = (Serializable) ois.readObject();
        } catch (final IOException | ClassNotFoundException e) {
            logger.warn("cannot Java deserialize object", e);
        }
        return o;
    }
1091499
def serialize(self):
        
        try:
            return jsonpickle.encode(self, unpicklable=False)
        except Exception:
            log.exception("got an exception during serialization")
22
def jsonify_payload(self):
        
        # Assume already json serialized
        if isinstance(self.payload, string_types):
            return self.payload
        return json.dumps(self.payload, cls=StandardJSONEncoder)
1010769
def to_bytes(self, exclude=tuple(), disable=None, **kwargs):
        
        if disable is not None:
            deprecation_warning(Warnings.W014)
            exclude = disable
        serializers = OrderedDict()
        serializers["vocab"] = lambda: self.vocab.to_bytes()
        serializers["tokenizer"] = lambda: self.tokenizer.to_bytes(exclude=["vocab"])
        serializers["meta.json"] = lambda: srsly.json_dumps(self.meta)
        for name, proc in self.pipeline:
            if name in exclude:
                continue
            if not hasattr(proc, "to_bytes"):
                continue
            serializers[name] = lambda proc=proc: proc.to_bytes(exclude=["vocab"])
        exclude = util.get_serialization_exclude(serializers, exclude, kwargs)
        return util.to_bytes(serializers, exclude)
1035907
public static JSONObject toJsonObject(byte[] bytes) {
        String json;
        try {
            json = new String(bytes, Const.UTF8);
            return new JSONObject(json);
        } catch (UnsupportedEncodingException e) {
            throw new WebbException(e);
        } catch (JSONException e) {
            throw new WebbException("payload is not a valid JSON object", e);
        }
    }
999439
def deserialize_transactions(self, transactions=None, deserialize_only=None):
        

        if (
            not self.allow_self
            and transactions.filter(producer=socket.gethostname()).exists()
        ):
            raise TransactionDeserializerError(
                f"Not deserializing own transactions. Got "
                f"allow_self=False, hostname={socket.gethostname()}"
            )
        for transaction in transactions:
            json_text = self.aes_decrypt(cipher_text=transaction.tx)
            json_text = self.custom_parser(json_text)
            deserialized = next(self.deserialize(json_text=json_text))
            if not deserialize_only:
                if transaction.action == DELETE:
                    deserialized.object.delete()
                else:
                    self.save(obj=deserialized.object, m2m_data=deserialized.m2m_data)
                transaction.is_consumed = True
                transaction.save()
1242158
def load_json(data=None, path=None, name='NT'):
    
    if data and not path:
        return mapper(json.loads(data), _nt_name=name)
    if path and not data:
        return mapper(json.load(path), _nt_name=name)
    if data and path:
        raise ValueError('expected one source and received two')
41812
public static Message deserializeObject( byte[] bytes )
	throws IOException, ClassNotFoundException {

		ByteArrayInputStream is = new ByteArrayInputStream( bytes );
		ObjectInputStream deserializer = new ObjectInputStream( is );
		return (Message) deserializer.readObject();
	}
733949
def from_json(cls, raw):
        
        if raw is None:
            return None

        bcls = None
        _type = raw.get('type')
        try:
            bcls = cls._blob_type_map[BlobType(_type)]
        except (KeyError, ValueError) as e:
            logger.warning('Unknown blob type: %s', _type)
            if DEBUG:
                raise_from(exception.ParseException('Parse error for %s' % (_type), raw), e)
            return None
        blob = bcls()
        blob.load(raw)

        return blob
973564
def _to_bytes(self, data):
        
        # TODO: On Python 3, move this `if` line to the `except` branch
        # as the common case will indeed no longer be bytes.
        if not isinstance(data, bytes):
            try:
                return data.encode('utf-8')
            except Exception:
                return None

        return data
458233
def load_bytecode_definitions(*, path=None) -> dict:
    
    if path is not None:
        with open(path, 'rb') as file_in:
            j = json.load(file_in)
    else:
        try:
            j = json.loads(pkgutil.get_data('jawa.util', 'bytecode.json'))
        except json.JSONDecodeError:
            # Unfortunately our best way to handle missing/malformed/empty
            # bytecode.json files since it may not actually be backed by a
            # "real" file.
            return {}

    for definition in j.values():
        # If the entry has any operands take the text labels and convert
        # them into pre-cached struct objects and operand types.
        operands = definition['operands']
        if operands:
            definition['operands'] = [
                [getattr(OperandFmts, oo[0]), OperandTypes[oo[1]]]
                for oo in operands
            ]

    # Return one dict that contains both mnemonic keys and opcode keys.
    return {**j, **{v['op']: v for v in j.values()}}
1104163
public static <T extends Serializable> T deserialize(byte[] bytes, boolean compressed) throws IOException, ClassNotFoundException {
        requireNonNull(bytes);

        try (ByteArrayInputStream i = new ByteArrayInputStream(bytes);
             ObjectInputStream ois = new ObjectInputStream(compressed ? new GZIPInputStream(i) : i)) {
            return (T) ois.readObject();
        }
    }
1031263
def from_bytes(cls, xbytes: bytes) -> 'BlsEntity':
        
        logger = logging.getLogger(__name__)
        logger.debug("BlsEntity::from_bytes: >>>")

        c_instance = c_void_p()
        do_call(cls.from_bytes_handler, xbytes, len(xbytes), byref(c_instance))

        res = cls(c_instance)

        logger.debug("BlsEntity::from_bytes: <<< res: %r", res)
        return res
924130
def json(self, **kwargs):
        '''
        
        '''
        body = self._decompress(self.encoding)
        return _json.loads(body, **kwargs)
1351894
def serialize(self, content):
        
        worker = JSONSerializer(
            scheme=self.resource,
            options=self.resource._meta.emit_options,
            format=self.resource._meta.emit_format,
            **self.resource._meta.emit_models
        )
        return worker.serialize(content)
809611
def deserialize(self):
        

        super(Deserializer, self).deserialize()

        try:
            return json.loads(self.req.get_body())
        except TypeError:
            link = 'tools.ietf.org/html/rfc7159'
            self.fail('Typically, this error is due to a missing JSON '
                      'payload in your request when one was required. '
                      'Otherwise, it could be a bug in our API.', link)
        except UnicodeDecodeError:
            link = 'tools.ietf.org/html/rfc7159#section-8.1'
            self.fail('We failed to process your JSON payload & it is '
                      'most likely due to non UTF-8 encoded characters '
                      'in your JSON.', link)
        except ValueError as exc:
            link = 'tools.ietf.org/html/rfc7159'
            self.fail('The JSON payload appears to be malformed & we '
                      'failed to process it. The error with line & column '
                      'numbers is: %s' % exc.message, link)