How to use the jsonpickle.encode 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 tech-quantum / sia-cog / ml / pipeline.py View on Github external
def Output(name, num = None):
    pipelinecomponents.init(pipelinecomponents, srvname, model_type, jobid)
    result = pipelinecomponents.return_result(name, num)
    return jsonpickle.encode(result, unpicklable=False)
github ButterFlyDevs / StudentsManagementSystem / SMS-Back-End / sbd / api.py View on Github external
@app.route('/alumnos//profesores',methods=['GET'])
def getProfesoresAlumno(id_alumno):
    '''
    Devuelve todos los profesores que imparten clase a ese alumno.
    curl -i -X GET localhost:8002/alumnos/1/profesores
    '''
    return jsonpickle.encode(GestorAlumnos.getProfesores(id_alumno))
github alexandrainst / ckanext-realtime / ckanext / realtime / event / event_dispatcher.py View on Github external
def dispatch_one(cls, event):
        cls.r.publish(event.channel_name, jsonpickle.encode(event))
github laincloud / console / apis / specs.py View on Github external
def json_of_spec(spec):
    return json.loads(jsonpickle.encode(spec, unpicklable=False))
github Almenon / AREPL-electron / src / python / pythonEvaluator.py View on Github external
def pickle_user_vars(userVars):
    # filter out non-user vars, no point in showing them
    userVariables = {k:v for k,v in userVars.items() if str(type(v)) != ""
                     and k not in specialVars+['__builtins__']}

    # json dumps cant handle any object type, so we need to use jsonpickle
    # still has limitations but can handle much more
    return jsonpickle.encode(userVariables, max_depth=100) # any depth above 245 resuls in error and anything above 100 takes too long to process
github Evilcry / malware-crawler / MalwareCrawler / src / reporting / hpfriends.py View on Github external
channel_files = self.options.get("channel_files")
        
        if not ident or not secret:
            raise Exception("HPFriends Identifier and Secret not configurated")
        
        try:
            # Connect to HPFriends
            hpc = hpfeeds.HPC(host, port, ident, secret, timeout=60)
            
            if channel_reports:
                # publish JSON-Report on the HPFriends channel
                log.info("publish JSON-Report on the HPFriends channel %s" % channel_reports)
                
                jsonpickle.set_encoder_options('simplejson', indent=4) 
                jsonpickle.handlers.registry.register(datetime.datetime, DatetimeHandler)
                hpc.publish(channel_reports, jsonpickle.encode(results))
            
            if channel_files:
                # publish RAW-File as BASE64 on the HPFriends channel
                log.info("publish BASE64 on the HPFriends channel %s" % channel_files)
                hpc.publish(channel_files, json.dumps(objfile.file.get_fileB64encode(), sort_keys=False, indent=4))
        except hpfeeds.FeedException as e:
            raise Exception("publish on the channel failed: %s" % e)
        finally:
            hpc.close()
github SkygearIO / chat / plugin / chat_plugin.py View on Github external
def _publish_event(participant_id, record_type, event_type, record,
        original_record=None):
    data = {
        'record_type': record_type,
        'event_type': event_type,
        'record': jsonpickle.encode(record, unpicklable=False),
        'original_record': jsonpickle.encode(
            original_record, unpicklable=False)
    }

    channel_name = _get_channel_by_user_id(participant_id)

    if channel_name:
        pubsub.publish(channel_name, data)
github nicholasdavidson / pybit / pybitweb / job.py View on Github external
    @app.route('/', method='GET')
    @app.route('/page/', method='GET')
    def get_jobs(page = None):
        try:
            response.content_type = "application/json"
            #return list of ALL jobs
            if page:
                return jsonpickle.encode(app.config['db'].get_jobs(page))
            else:
                return jsonpickle.encode(app.config['db'].get_jobs())
        except Exception as e:
            raise Exception('Exception encountered: ' + str(e))
            return None
github botfront / rasa-for-botfront / rasa / core / events / __init__.py View on Github external
def __members(self):
        data_no_nones = utils.remove_none_values(self.data)
        meta_no_nones = utils.remove_none_values(self.metadata)
        return (
            self.text,
            jsonpickle.encode(data_no_nones),
            jsonpickle.encode(meta_no_nones),
        )
github czhuang / ChordRipple / app / Database.py View on Github external
def format(self, obj, store_attrs=True):
        store_dict = {}
        # TODO: resolve hack parent ref
        if hasattr(obj, 'parent'):
            parent = obj.parent
            obj.parent = None
            obj_json = jsonpickle.encode(obj)
        else:
            obj_json = jsonpickle.encode(obj)

        obj_type = type(obj).__name__
        store_dict[obj_type+"_json"] = obj_json

        if store_attrs:
            # TODO:  add a function in each object to serialize
            # so that can add side information
            for attr in obj.__dict__.keys():
                store_dict[attr] = getattr(obj, attr)

        # for key, val in store_dict.iteritems():
        #     print key, ':', val
        # return json.dumps(store_dict)

        # TODO: resolve hack, restore parent ref
        if hasattr(obj, 'parent'):