How to use the jsonpickle.dumps function in jsonpickle

To help you get started, we’ve selected a few jsonpickle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glotzerlab / signac / src / signac / core / mongodb_set.py View on Github external
def encode_element(element):
    binary = json.dumps(json.loads(jsonpickle.dumps(element)), sort_keys=True).encode()
    return binary
github apache / incubator-ariatosca / aria / orchestrator / workflows / executor / process.py View on Github external
def _send_message(connection, message):

    # Packing the length of the entire msg using struct.pack.
    # This enables later reading of the content.
    def _pack(data):
        return struct.pack(_INT_FMT, len(data))

    data = jsonpickle.dumps(message)
    msg_metadata = _pack(data)
    connection.send(msg_metadata)
    connection.sendall(data)
github jpalladino84 / Python-Roguelike-Framework / data / json_template_loader.py View on Github external
def _save_templates_file(full_path, templates):
        with open(full_path, 'w') as new_json_file:
            new_json_file.write(jsonpickle.dumps(templates))
github glotzerlab / signac / signac / core / serialization.py View on Github external
def encode_callable(fn, args, kwargs):
    checksum_src = hash_source(fn)
    doc = dict(
        fn=fn, args=args, kwargs=kwargs,
        module=fn.__module__, checksum_src=checksum_src)
    # we need jsonpickle to encode the functions and
    # json to ensure key sorting
    binary = json.dumps(json.loads(jsonpickle.dumps(doc)),
                        sort_keys=True).encode()
    m = hashlib.sha1()
    m.update(binary)
    checksum = m.hexdigest()
    return {KEY_CALLABLE: binary, KEY_CALLABLE_CHECKSUM: checksum}
github purduesigbots / pros-cli / pros / common / ui / __init__.py View on Github external
def _machineoutput(obj: Dict[str, Any]):
    click.echo(f'Uc&42BWAaQ{jsonpickle.dumps(obj, unpicklable=False, backend=_machine_pickler)}')
github robmcmullen / omnivore / sawx / document.py View on Github external
def save_session(self, editor_id, editor_session):
        if not self.session_save_file_extension:
            log.debug("no filename extension for session data; not saving")
        else:
            s = {}
            self.serialize_session(s)
            if s and editor_session:
                s[editor_id] = editor_session
                jsonpickle.set_encoder_options("json", sort_keys=True, indent=4)
                text = jsonpickle.dumps(s)
                text = jsonutil.collapse_json(text, 8, self.json_expand_keywords)
                path = self.save_adjacent(self.session_save_file_extension, text)
                log.debug("saved session to {path}")
                return path