forked from turian/common
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson.py
More file actions
28 lines (24 loc) · 674 Bytes
/
json.py
File metadata and controls
28 lines (24 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
JSON convenience routines.
"""
import simplejson
loads = simplejson.loads
dumps = simplejson.dumps
load = simplejson.load
dump = simplejson.dump
from common.file import myopen
def loadfile(filename):
"""
Load JSON from a filename.
"""
return load(myopen(filename))
def dumpfile(object, filename):
"""
Dump JSON to a filename.
"""
return dump(object, myopen(filename, "wb"))
import jsonlib
def fastloads(str): return jsonlib.read(str, use_float=True)
fastdumps = jsonlib.write
def fastloadfile(filename): return jsonlib.read(myopen(filename).read(), use_float=True)
def fastload(file): return jsonlib.read(file.read(), use_float=True)