How to use the jsonpickle.loads 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 robmcmullen / omnivore / test / test_atrip_collection.py View on Github external
def test_serialize(self):
        filename = "dos_sd_test1.atr"
        pathname = os.path.join(os.path.dirname(__file__), "../samples", filename)
        c = Collection(pathname)
        m = c.containers[0].media
        m.set_comment_at(100, "at location 100")
        m.set_comment_at(1000, "at location 1000")
        m.set_comment_at(10000, "at location 10000")
        s = {}
        c.serialize_session(s)
        print(s)

        j = jsonpickle.dumps(s)
        print(j)
        
        sprime = jsonpickle.loads(j)
        jprime = jsonpickle.dumps(sprime)
        print(jprime)

        assert j == jprime

        c2 = Collection(pathname, session=sprime)
        s2 = {}
        m2 = c2.containers[0].media
        assert m2.get_comment_at(100) == "at location 100"
        assert m2.get_comment_at(1000) == "at location 1000"
        assert m2.get_comment_at(10000) == "at location 10000"
        c2.serialize_session(s2)
        j2 = jsonpickle.dumps(s2)
        assert j == j2
github glotzerlab / signac / src / signac / core / mongodb_set.py View on Github external
def decode_element(binary):    
    return jsonpickle.loads(binary.decode())
github worthwhile / django-herald / herald / models.py View on Github external
def get_attachments(self):
        if self.attachments:
            return jsonpickle.loads(self.attachments)
        else:
            return None
github apache / incubator-ariatosca / aria / storage / drivers.py View on Github external
def get(self, name, entry_id, **kwargs):
        """
        Getter from storage.
        :param str name: name of directory in storage.
        :param str entry_id: id of the file to get from storage.
        :return: value of file from storage.
        :rtype: dict
        """
        with open(self._join_path(name, entry_id)) as file_obj:
            return jsonpickle.loads(file_obj.read())
github JarnoRFB / incense / incense / experiment.py View on Github external
def from_db_object(cls, database, grid_filesystem, experiment_data: dict, loader, unpickle: bool = True):
        if unpickle:
            experiment_data["info"] = jsonpickle.loads(json.dumps(experiment_data["info"]))
        data = freeze(experiment_data)

        artifacts_links = experiment_data["artifacts"]
        id_ = experiment_data["_id"]
        return cls(id_, database, grid_filesystem, data, artifacts_links, loader)
github apache / incubator-ariatosca / aria / orchestrator / workflows / executor / process.py View on Github external
def _recv_message(connection):
    # Retrieving the length of the msg to come.
    def _unpack(conn):
        return struct.unpack(_INT_FMT, _recv_bytes(conn, _INT_SIZE))[0]

    msg_metadata_len = _unpack(connection)
    msg = _recv_bytes(connection, msg_metadata_len)
    return jsonpickle.loads(msg)
github jpalladino84 / Python-Roguelike-Framework / data / json_template_loader.py View on Github external
def _load_template_file(full_path, template_name):
        if os.path.isfile(full_path):
            with open(full_path, 'r') as open_json_file:
                return jsonpickle.loads(open_json_file.read())
        else:
            logger_.error(template_name + " template file not found at " + full_path)