Mercurial > hg > piper-cpp
changeset 35:54676b4e224e
Since JSON is no longer the "fast" protocol format, might as well use the non-b64 encoding by default now
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 25 May 2016 14:18:36 +0100 |
parents | ba58fe5ee2dd |
children | 1307d0d7e3ed |
files | json/VampJson.h |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/json/VampJson.h Wed May 25 11:09:18 2016 +0100 +++ b/json/VampJson.h Wed May 25 14:18:36 2016 +0100 @@ -308,11 +308,17 @@ } static json11::Json - fromFeature(const Vamp::Plugin::Feature &f) { + fromFeature(const Vamp::Plugin::Feature &f, bool asText) { json11::Json::object jo; if (f.values.size() > 0) { - jo["b64values"] = fromFloatBuffer(f.values.data(), f.values.size()); + if (asText) { + jo["values"] = json11::Json::array(f.values.begin(), + f.values.end()); + } else { + jo["b64values"] = fromFloatBuffer(f.values.data(), + f.values.size()); + } } if (f.label != "") { jo["label"] = f.label; @@ -353,13 +359,13 @@ } static json11::Json - fromFeatureSet(const Vamp::Plugin::FeatureSet &fs) { + fromFeatureSet(const Vamp::Plugin::FeatureSet &fs, bool asText) { json11::Json::object jo; for (const auto &fsi : fs) { std::vector<json11::Json> fj; for (const Vamp::Plugin::Feature &f: fsi.second) { - fj.push_back(fromFeature(f)); + fj.push_back(fromFeature(f, asText)); } std::stringstream sstr; sstr << fsi.first; @@ -946,7 +952,7 @@ jo["type"] = "process"; jo["success"] = true; jo["errorText"] = ""; - jo["content"] = fromFeatureSet(resp.features); + jo["content"] = fromFeatureSet(resp.features, true); return json11::Json(jo); } @@ -969,7 +975,7 @@ jo["type"] = "finish"; jo["success"] = true; jo["errorText"] = ""; - jo["content"] = fromFeatureSet(resp.features); + jo["content"] = fromFeatureSet(resp.features, true); return json11::Json(jo); }