Questions tagged [jsonpickle]

jsonpickle is a Python library for serialization and deserialization of complex Python objects to and from JSON.

jsonpickle is a Python library for serialization and deserialization of complex Python objects to and from JSON. The standard Python libraries for encoding Python into JSON, such as the stdlib’s json, simplejson, and demjson, can only handle Python primitives that have a direct JSON equivalent (e.g. dicts, lists, strings, ints, etc.). jsonpickle builds on top of these libraries and allows more complex data structures to be serialized to JSON. jsonpickle is highly configurable and extendable–allowing the user to choose the JSON backend and add additional backends.

93 questions
1
vote
1 answer

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnpicklingError: invalid load key, 'H'

I have searched all through Stackoverflow and I can't find a fix, Granted a lot of other people have the same error they didn't really help when I looked them up. The error is: CommandInvokeError: Command raised an exception: UnpicklingError:…
Zemo Artz
  • 11
  • 3
1
vote
1 answer

Override __getstate__ for jsonpickle but not for deepcopy

I want to hide some (private) attributes when pickling an object instance (to send to a json-api endpoint). I've added a __getstate__ function to that effect, but the side effect is that deepcopy also makes use of __getstate__. I don't want to…
Liz
  • 1,421
  • 5
  • 21
  • 39
1
vote
2 answers

is it possible to ujson.dumps() python class instance (faster deepcopy)

I am trying to make a fast copy of a class instance. cPickle.loads(cPickle.dumps(),-1) works fine, almost 5 times faster than copy.deepcopy, but I read that ujson is much faster than cPickle. I could not get ujson to work with a custom class, is it…
muon
  • 12,821
  • 11
  • 69
  • 88
1
vote
0 answers

Can't import jsonpickle

I'm using jsonpickle (https://jsonpickle.github.io/) to serialize my Python Objects. But can't even seem to import without getting an error. Everything was installed using pip. Getting the following error: In [2]: import…
zee
  • 656
  • 2
  • 7
  • 30
1
vote
2 answers

how to serializer list object in sqlalchemy?

I use jsonpickle for serializer when i selectall to database, i am going to convert list object to json when use jsonpickle for this i get this output: Codes: Session = sessionmaker(bind=connect.ConnectorMySql()) ses =…
Ramin Farajpour Cami
  • 1,605
  • 3
  • 11
  • 21
1
vote
1 answer

KeyError reading json_pickle(d) tweets into dataframe using read_pickle

Using python 2.7 and the jsonpickle and pandas library I saved a number of tweets to a .txt file using jsonfile.write(jsonpickle.encode(tweets._json,unpicklable=False)+'\n') which encodes the json value of the tweet using the jsonpickle…
mobcdi
  • 1,532
  • 2
  • 28
  • 49
1
vote
1 answer

Serialise child collections in Python (with jsonpickle)

I'd like to serialise a python list that contains nested lists. The code below constructs the object to be serialised from a gnome keyring but the jsonpickle encoder, doesn't serialise the child lists. With unpicklable=True, I simply…
grenade
  • 31,451
  • 23
  • 97
  • 126
1
vote
1 answer

jsonpickle force using __dict__ due to type evolution

This question is related to type evolution with jsonpickle (python) Current state description: I need to store an object to a JSON file using jsonpickle in python. The object class CarState is generated by a script from another software component…
Stefan Profanter
  • 6,458
  • 6
  • 41
  • 73
1
vote
1 answer

How to install jsonpickle in Linux?

I'm now attempting to program in python on Linux. I am using Linux Mint 15 "Olivia" with Cinnamon desktop. I'm also using python 3.3 now. Being new to Linux, I am unable to find anything regarding getting jsonpickle to work. If someone would be kind…
JohnBobSmith
  • 159
  • 1
  • 3
  • 10
1
vote
1 answer

jsonpickle ignores maxlen of collection deque

I try to save and restore a collection.deque list with jsonpickle but the maxlen parameter gets lost in the process. original_test = deque(maxlen=2) original_test.append(1) original_test.append(2) print(original_test) >>> deque([1, 2], maxlen=2) #…
fanti
  • 1,859
  • 3
  • 16
  • 31
1
vote
2 answers

type evolution with jsonpickle (python)

Is there any support of this in jsonpickle? E.g. I store and object, them modify its schema, then try to load it back. The following change, for instance, (attribute addition) import jsonpickle class Stam(object): def __init__(self, a): …
Srg
  • 510
  • 4
  • 13
0
votes
1 answer

Create nested json object using python jsonpickle

I want to build nested json object using python jsonpickle, something like this {"key": "value", "key2": { "key2": "value2", "key": "value"} } } using jsonpickele set value to variable name and def…
UdayaLakmal
  • 4,035
  • 4
  • 29
  • 40
0
votes
1 answer

how to reinitialize the class instance decoded from jsonpickle

Lets say I have this class class LineItem: def __init__(self): self.var1 = 1 When I encode this json with JSON pickle it will save all the attributes and class definition. And after encoding, lets say I change the class to…
Mamoon Ahmed
  • 113
  • 10
0
votes
0 answers

pkl file is too large to load

I am trying to learn python and deep learning recently. My teacher sent me a pkl file which contains the data I need. The size of pkl file is 9.6GB. My memory is only 16g. When I try to load the whole file with pickle.load(open('data.pkl', 'rb')),…
0
votes
0 answers

get output in json format

from flask import Flask,jsonify from flask_sqlalchemy import SQLAlchemy import os import jsonpickle app = Flask(__name__) # the name of the database; add path if necessary db_name = 'student.db' app.config['SQLALCHEMY_DATABASE_URI'] =…
Randi
  • 61
  • 7