Skip to content

Commit

Permalink
Merge pull request #20 from Scifabric/fix-utf8-issue
Browse files Browse the repository at this point in the history
Fix utf8 issue
  • Loading branch information
amirziai committed Jun 16, 2017
2 parents 39d3152 + 4ce58b4 commit 5bbe314
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flatten_json.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Iterable

from util import check_if_numbers_are_consecutive
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='flatten_json',
packages=[''],
version='0.1.5',
version='0.1.6',
description='Flatten JSON objects',
author='Amir Ziai',
author_email='arziai@gmail.com',
Expand Down
12 changes: 12 additions & 0 deletions test_flatten.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest

from flatten_json import flatten, unflatten, unflatten_list
Expand Down Expand Up @@ -42,6 +45,15 @@ def test_one_flatten(self):
actual = flatten(dic)
self.assertEqual(actual, expected)

def test_one_flatten_utf8(self):
dic = {'a': '1',
'ñ': 'áéö',
'c': {'c1': '3', 'c2': '4'}
}
expected = {'a': '1', 'ñ': 'áéö', 'c_c1': '3', 'c_c2': '4'}
actual = flatten(dic)
self.assertEqual(actual, expected)

def test_custom_separator(self):
dic = {'a': '1',
'b': '2',
Expand Down

0 comments on commit 5bbe314

Please sign in to comment.