Linked Questions

1507 votes
46 answers
1.7m views

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('/...
Sergey's user avatar
  • 21.5k
338 votes
12 answers
216k views

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 ...
Teifion's user avatar
  • 112k
2 votes
0 answers
575 views

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: ...
User91234's user avatar
0 votes
1 answer
279 views

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 ...
B. Latif's user avatar
83 votes
4 answers
115k views

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

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
31 votes
7 answers
44k views

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
2 votes
2 answers
13k views

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.
KCReddy's user avatar
  • 29
6 votes
2 answers
11k views

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 ...
Mike Makarov's user avatar
  • 1,366
3 votes
2 answers
7k views

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....
iec2011007's user avatar
  • 1,844
0 votes
1 answer
6k views

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 ...
aceminer's user avatar
  • 4,365
1 vote
1 answer
6k views

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 ...
Saurabh Gokhale's user avatar
2 votes
1 answer
2k views

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, ...
cgajardo's user avatar
  • 364
0 votes
1 answer
4k views

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,069
0 votes
1 answer
945 views

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 ...
Akrix's user avatar
  • 52

15 30 50 per page