Skip to content

Commit 26d73e2

Browse files
author
Gauvain Pocentek
committed
Merge branch 'fix-json' of https://github.com/rhansen/python-gitlab into rhansen-fix-json
2 parents 3f38689 + ca6da62 commit 26d73e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gitlab/objects.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131

3232
class jsonEncoder(json.JSONEncoder):
3333
def default(self, obj):
34+
from gitlab import Gitlab
3435
if isinstance(obj, GitlabObject):
35-
return obj.__dict__
36+
return {k: v for k, v in obj.__dict__.iteritems()
37+
if not isinstance(v, BaseManager)}
3638
elif isinstance(obj, Gitlab):
3739
return {'url': obj._url}
3840
return json.JSONEncoder.default(self, obj)
@@ -474,7 +476,7 @@ def json(self):
474476
Returns:
475477
str: The json string.
476478
"""
477-
return json.dumps(self.__dict__, cls=jsonEncoder)
479+
return json.dumps(self, cls=jsonEncoder)
478480

479481

480482
class UserKey(GitlabObject):

0 commit comments

Comments
 (0)