diff options
| author | Zhongyue Luo <lzyeval@gmail.com> | 2012-06-03 18:00:00 +0800 |
|---|---|---|
| committer | Zhongyue Luo <lzyeval@gmail.com> | 2012-06-04 18:14:38 +0800 |
| commit | 72840edc736b7f4d2366b5049f6516d8f5b901ff (patch) | |
| tree | 6ce6001dec954a72afce1e3af96f2b9cbe107bdc /openstack/common | |
| parent | 141fe5b9741296f72b0695a85089fd1a0b2c2173 (diff) | |
| download | oslo-72840edc736b7f4d2366b5049f6516d8f5b901ff.tar.gz oslo-72840edc736b7f4d2366b5049f6516d8f5b901ff.tar.xz oslo-72840edc736b7f4d2366b5049f6516d8f5b901ff.zip | |
Add a load function wrapper to jsonutils
Fixes bug #1008065
Change-Id: I72aba29eea4637643cb7742f2fd4b1f05d15667f
Diffstat (limited to 'openstack/common')
| -rw-r--r-- | openstack/common/jsonutils.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py index fa8b8f9..f0a3e6e 100644 --- a/openstack/common/jsonutils.py +++ b/openstack/common/jsonutils.py @@ -25,11 +25,11 @@ This module provides a few things: 1) A handy function for getting an object down to something that can be JSON serialized. See to_primitive(). - 2) Wrappers around loads() and dumps(). The dumps() wrapper will + 2) Wrappers around load(), loads() and dumps(). The dumps() wrapper will automatically use to_primitive() for you if needed. - 3) This sets up anyjson to use the loads() and dumps() wrappers if anyjson - is available. + 3) This sets up anyjson to use the load(), loads() and dumps() wrappers + if anyjson is available. ''' @@ -119,6 +119,10 @@ def dumps(value): return json.dumps(value, default=to_primitive) +def load(s): + return json.load(s) + + def loads(s): return json.loads(s) @@ -129,5 +133,6 @@ except ImportError: pass else: anyjson._modules.append((__name__, 'dumps', TypeError, + 'load', ValueError, 'loads', ValueError)) anyjson.force_implementation(__name__) |
