diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-12 09:40:12 -0800 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-12 09:40:12 -0800 |
commit | 8b12a186b645a6c6bc71e84be5cfc66a3a90dd73 (patch) | |
tree | 2970a515f7a59732bfa269b021138dc8adc7e08f /src/rgw/rgw_common.cc | |
parent | adca757223b4118ffcf1810264e320d7bd263053 (diff) | |
download | ceph-wip-json-decode.tar.gz |
rgw: add encode_jsonwip-json-decode
dump() just dumps the internal content of an object, encode_json()
create the object inside its own section. Note that there are cases
where we don't want an object to be surrounded by a section, e.g.,
when an object represents an array. In such a case we'd need to
override the encode_json() for this object type.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/rgw/rgw_common.cc')
-rw-r--r-- | src/rgw/rgw_common.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 0fcc941a4a5..9bc1866ca55 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -707,7 +707,12 @@ int RGWUserCaps::remove_from_string(const string& str) void RGWUserCaps::dump(Formatter *f) const { - f->open_array_section("caps"); + dump(f, "caps"); +} + +void RGWUserCaps::dump(Formatter *f, const char *name) const +{ + f->open_array_section(name); map<string, uint32_t>::const_iterator iter; for (iter = caps.begin(); iter != caps.end(); ++iter) { @@ -748,6 +753,11 @@ struct RGWUserCap { } }; +void encode_json(const char *name, const RGWUserCaps& val, Formatter *f) +{ + val.dump(f, name); +} + void RGWUserCaps::decode_json(JSONObj *obj) { list<RGWUserCap> caps_list; |