1
0

interface: use parse_json

This commit is contained in:
ThomasV
2014-07-26 16:24:22 +02:00
parent 9a07c1cb44
commit 9efc25bdba
4 changed files with 22 additions and 21 deletions

View File

@@ -211,3 +211,15 @@ def raw_input(prompt=None):
import __builtin__
builtin_raw_input = __builtin__.raw_input
__builtin__.raw_input = raw_input
def parse_json(message):
n = message.find('\n')
if n==-1:
return None, message
try:
j = json.loads( message[0:n] )
except:
j = None
return j, message[n+1:]