Skip to content

Instantly share code, notes, and snippets.

@mikhail
Created July 9, 2018 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikhail/39ab2253767619512bbe17c9b2bc7d7a to your computer and use it in GitHub Desktop.
Save mikhail/39ab2253767619512bbe17c9b2bc7d7a to your computer and use it in GitHub Desktop.
In [1]: b = object()
In [2]: import json
In [3]: json.dumps(b)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-8c425ddada75> in <module>()
----> 1 json.dumps(b)
/var/lib/conda/envs/nextdoor3/lib/python3.6/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
229 cls is None and indent is None and separators is None and
230 default is None and not sort_keys and not kw):
--> 231 return _default_encoder.encode(obj)
232 if cls is None:
233 cls = JSONEncoder
/var/lib/conda/envs/nextdoor3/lib/python3.6/json/encoder.py in encode(self, o)
197 # exceptions aren't as detailed. The list call should be roughly
198 # equivalent to the PySequence_Fast that ''.join() would do.
--> 199 chunks = self.iterencode(o, _one_shot=True)
200 if not isinstance(chunks, (list, tuple)):
201 chunks = list(chunks)
/var/lib/conda/envs/nextdoor3/lib/python3.6/json/encoder.py in iterencode(self, o, _one_shot)
255 self.key_separator, self.item_separator, self.sort_keys,
256 self.skipkeys, _one_shot)
--> 257 return _iterencode(o, 0)
258
259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
/var/lib/conda/envs/nextdoor3/lib/python3.6/json/encoder.py in default(self, o)
178 """
179 raise TypeError("Object of type '%s' is not JSON serializable" %
--> 180 o.__class__.__name__)
181
182 def encode(self, o):
TypeError: Object of type 'object' is not JSON serializable
In [4]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment