Skip to content

Commit

Permalink
fix: fix a bug when inspect list
Browse files Browse the repository at this point in the history
  • Loading branch information
Humbertzhang committed Oct 31, 2018
1 parent abbb17c commit 5866eb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@ False
```

关于flask或aiohttp的例子请见example



`https://www.cnblogs.com/sting2me/p/6550897.html`
10 changes: 9 additions & 1 deletion jsoncensor/jsoncensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check(self):
return self.ret

#字典情况
if type(_standard) == type(_suspect) and type(_standard) is dict:
elif type(_standard) == type(_suspect) and type(_standard) is dict:
#1,Key 数目检查
if len(_standard.keys()) != len(_suspect.keys()):
self._set_ret(False, "KeyNumberError", str(', '.join(_suspect.keys())), str(', '.join(_standard.keys())))
Expand All @@ -65,6 +65,14 @@ def check(self):
#3, 将Value加入到Queue中
for key in _standard_keys:
self.checkqueue.put( (str(key), _standard[key], _suspect[key]) )

# 列表情况
elif type(_standard) == type(_suspect) and type(_standard) is list:
if len(_standard) is 0 and len(_suspect) is 0:
continue
else:
self.checkqueue.put( ("list", _standard[0], _suspect[0]) )


#Set True return
self._set_ret(True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'jsoncensor',
version = '0.0.8',
version = '0.1.0',
description = 'Check json data in your python web service.',
url = 'https://github.com/Humbertzhang/jsoncensor',
author = 'HumbertZhang',
Expand Down

0 comments on commit 5866eb2

Please sign in to comment.