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
2
votes
0 answers

Used jsonpickle to serialize Twitter search API results in Python, can't decode

I wasn't able to serialize Twitter API results until I used jsonpickle (that's code A below), but then I wasn't able to decode the json file (code B below). Code A created one large json object. Please help. Code A #!/usr/bin/env python import…
atr15
  • 21
  • 2
2
votes
1 answer

Pickle not able to save dataframes

I am trying to use pickle to save few large datasets that I generate through other datasets. While dumping it does not give me any error but when I try to load these datasets pickle exits with an eof error. Below is the code that I run to save the…
Sudh
  • 1,265
  • 2
  • 19
  • 30
2
votes
1 answer

Jsonpickle Encoding Floats with Many Decimals as Null

I've encountered this problem a few times in my code and have been unable to reproduce it in a small case, but I'm hoping someone can point me in the right direction. It occurs when creating a save object (which basically packages up different parts…
The Bearded Templar
  • 671
  • 1
  • 7
  • 16
2
votes
1 answer

Import error: No module named jsonpickle

I get the following error:- File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 239, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File…
Irfan
  • 1,758
  • 3
  • 24
  • 32
2
votes
2 answers

Python package import subpackage - good practice?

My package has a dependency on the latest version of the jsonpickle package. Older versions are installable via pip, however I need the latest version (i.e on Github) for it to work. Is it generally considered OK in this situation to bundle the…
Mike Vella
  • 10,187
  • 14
  • 59
  • 86
1
vote
0 answers

jsonpickle does not apply unpickable to the nested object

I would like to use jsonpickle to serialise my complex object with unpicklable=False. However, the unpicklable only applies to the first object, rather than the nested one. I have the following object to serialise T = TypeVar('T') class…
Ben
  • 957
  • 1
  • 11
  • 37
1
vote
1 answer

jsonpickle returns False on check instance

I wonder why the jsonpickle-module when consecutively applying or calling encode & decode does not pass the isinstance(...) check in Python 3.8. Let say i have a simple class Person. Here some code to illustrate what i mean: import…
Manifest Man
  • 873
  • 10
  • 16
1
vote
1 answer

Wierd jsonpickle.encode behavior

I'm using jsonpickle as a database for my small project and encountered some weird behavior when encoding a complex class, basically Book from a User instance is encoded correctly but books in db list are encoded as strange {"py/id":4}-s. Could…
LukaSsS
  • 100
  • 5
1
vote
1 answer

Python: create jsonpickle from a class and unpack, Error AttributeError: type object ' ' has no attribute 'decode'

So, I have class that I use in a Flask app. I use this class in multiple pages, which is why I would like to save the creates class object in a pickle, and unpack it when I need it again. It just keeps on giving me errors.. I have a class that looks…
user2133561
  • 155
  • 1
  • 10
1
vote
1 answer

How to decode jsonpickle data in angular typescript file

I'm creating an hobby application where Angular is front-end and Python is acting as back-end. A component in Angular is sending HTTP GET to Python upon which python responds with a jsonpickled object. I wish to unpickle (decode) the jsonpickled…
1
vote
1 answer

jsonpickle: How to correctly encode and display duplicate objects rather than references?

I'm trying to get jsonpickle to dump the data such that duplicate items are explicitly displayed rather than using references. I tried encoding with make_refs=False, which prevented it from using the py/id references but still didn't explicitly show…
fny82
  • 185
  • 3
  • 13
1
vote
0 answers

How to serialize a Python class using jsonpickle?

I am running the following code on VS Code to serialize a Python class: import json import jsonpickle import sys class P_C(object): def __init__(self, name = "default name", items = None): self.name = name self.items = items …
Diego
  • 386
  • 4
  • 19
1
vote
1 answer

Getting unwanted escape character in JSON using Python's Flask and jsonpickle

from flask import Flask, request, abort from flask_restful import Api, Resource import jsonpickle app = Flask(__name__) api = Api(app) user_dict = {} user_id = 0 class User(Resource): @staticmethod def get(path_user_id): if…
ShadyBears
  • 3,955
  • 13
  • 44
  • 66
1
vote
1 answer

Json to object and back in python like java

I am using jsonpickle which creates JSON with "py/object" with parameter unpicklable=True. If I need unpicklable=False type simple JSON, is there any library which does this like in Java? It is very weird to put long "py/object" names in JSON.as…
vipin
  • 152
  • 12
1
vote
1 answer

jsonpickle adds leading underscore to python object properties

I am using jsonpickle to turn a nested python object into json. Python class: class Cvideo: def __init__(self): self._url = None @property def url(self): return self._url @url.setter def url(self, value): …
wuz
  • 483
  • 3
  • 16