Skip to content

Commit

Permalink
module is now in a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
amirziai committed Apr 13, 2016
1 parent ea83a24 commit 946b104
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions flatten_json/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from flatten_json import flatten_json
23 changes: 23 additions & 0 deletions flatten_json/flatten_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def flatten_json(y):
out = {}

def flatten(x, name=''):
if type(x) is dict:
for a in x:
flatten(x[a], name + a + '_')
elif type(x) is list:
i = 0
for a in x:
flatten(a, name + str(i) + '_')
i += 1
else:
a = ''
try:
a = str(x)
except:
a = x.encode('ascii', 'ignore').decode('ascii')

out[str(name[:-1])] = a

flatten(y)
return out
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md

0 comments on commit 946b104

Please sign in to comment.