This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from dashpay/develop
release Sentinel version 1.2.0
- Loading branch information
Showing
18 changed files
with
376 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import simplejson | ||
|
||
|
||
def valid_json(input): | ||
""" Return true/false depending on whether input is valid JSON """ | ||
is_valid = False | ||
try: | ||
simplejson.loads(input) | ||
is_valid = True | ||
except: | ||
pass | ||
|
||
return is_valid | ||
|
||
|
||
def extract_object(json_input): | ||
""" | ||
Given either an old-style or new-style Proposal JSON string, extract the | ||
actual object used (ignore old-style multi-dimensional array and unused | ||
string for object type) | ||
""" | ||
if not valid_json(json_input): | ||
raise Exception("Invalid JSON input.") | ||
|
||
obj = simplejson.loads(json_input, use_decimal=True) | ||
|
||
if (isinstance(obj, list) and | ||
isinstance(obj[0], list) and | ||
(isinstance(obj[0][0], str) or (isinstance(obj[0][0], unicode))) and | ||
isinstance(obj[0][1], dict)): | ||
obj = obj[0][1] | ||
|
||
return obj |
Oops, something went wrong.