Linked Questions
28 questions linked to/from Serializing class instance to JSON
1509
votes
46
answers
1.7m
views
How to make a class JSON serializable
How to make a Python class serializable?
class FileItem:
def __init__(self, fname):
self.fname = fname
Attempt to serialize to JSON:
>>> import json
>>> x = FileItem('/...
338
votes
12
answers
216k
views
difference between variables inside and outside of __init__() (class and instance attributes)
Is there any difference at all between these classes besides the name?
class WithClass ():
def __init__(self):
self.value = "Bob"
def my_func(self):
print(self.value)
class ...
2
votes
0
answers
579
views
How to serialize custom objects into JSON? [duplicate]
I have a python module that will generate thousands of classes that will be used for http calls.
These classes must be converted to JSON objects to make the call.
When I try a simple example like:
...
0
votes
1
answer
281
views
How to JSON Serialize a Python Class Object? [duplicate]
My goal is to write the response I get from a call to Amazon's Product Advertising API to a file in JSON format.
I call the API using
response = default_api.search_items(search_items_request)
I ...
83
votes
4
answers
115k
views
Convert dynamic python object to json [duplicate]
I need to know how to convert a dynamic python object into JSON. The object must be able to have multiple levels object child objects. For example:
class C(): pass
class D(): pass
c = C()
c....
Trevor's user avatar
- 13.5k
33
votes
4
answers
54k
views
Python serializable objects json [duplicate]
class gpagelet:
"""
Holds 1) the pagelet xpath, which is a string
2) the list of pagelet shingles, list
"""
def __init__(self, parent):
if not isinstance( parent, ...
user avatar
asdfgaeg
31
votes
7
answers
44k
views
Easiest way to serialize a simple class object with simplejson?
I'm trying to serialize a list of python objects with JSON (using simplejson) and am getting the error that the object "is not JSON serializable".
The class is a simple class having fields that are ...
user avatar
user248237
2
votes
2
answers
13k
views
How to convert variables to json?
ip_adrs_ve100_lst = ['5.5.5.1', '5.5.5.2']
at_ip_1 = '10.10.10.1'
at_ip_2 = '10.10.10.2'
to json format.
6
votes
2
answers
11k
views
Is there no universal object serialization method in Python (to json)?
I'm learning Python but have a good 13+ years experience in other languages.
Today I studied the JSON serialization in Python and as far as I understand, not just the default json module but also ...
3
votes
2
answers
7k
views
Serializing a Python class
I have a sample Python class
class bean :
def __init__(self, puid, pogid, bucketId, dt, at) :
self.puid = puid
self.pogid = pogid
self.bucketId = bucketId
self.dt = (datetime....
0
votes
1
answer
6k
views
Passing objects between python and java via json
I would need some interprocess communication via stdin and stdout between a python script and a java engine.
Is there anyway I could convert a python object into JSON and converting this whole object ...
1
vote
1
answer
6k
views
Serialize List of Python Objects to JSON
I've searched SO's posts but couldn't figure out solution to my problem. I've seen bunch of SO posts which explains how to serialize python objects haven't found anything which explains how to ...
2
votes
1
answer
2k
views
Why is this class not JSon serializable? [duplicate]
I have this class in Python 3.5:
class DataPoint(object):
def __init__(self, time, value):
self.time = time
self.value = value
And when I try to create a JSon from an instance, ...
0
votes
1
answer
4k
views
AttributeError: 'dict' object has no attribute while converting json string to Python Object
I am new to Python and learning python. I have a requirement where I need to convert Python object to Json String and Json String to Python object just like what we do in Jackson in Java. I am able to ...
Sambit's user avatar
- 8,065
0
votes
1
answer
951
views
Replit DB Circular Reference Detected
Recently, I was programming a Python MMORPG using repl.it's database system. However, I ran into an error that I have no idea how to fix. I am trying to make a key in the database that lists all the ...