Skip to content

Commit

Permalink
fix python 2.6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKliszowski committed Jan 10, 2017
1 parent 01c7878 commit d50c4d7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions json_reindent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ def ordered_load(stream, use_collections=True):


def json_ordered_load(stream, object_pairs_hook):
return json.loads(
stream,
strict=False,
object_pairs_hook=object_pairs_hook)
params = {
's': stream,
'strict': False,
'object_pairs_hook': object_pairs_hook
}

try:
return json.loads(**params)
except TypeError:
# Fix python 2.6
del params['object_pairs_hook']
return json.loads(**params)


def yaml_ordered_load(stream, object_pairs_hook, Loader=yaml.Loader):
Expand Down

0 comments on commit d50c4d7

Please sign in to comment.