Mercurial > hg > piper-cpp
comparison utilities/vampipe-convert.cpp @ 66:6f160dee1192
Instead of using separate values and b64values entries in JSON serialisations, allow numeric arrays to be replaced by b64 variants wherever they appear (discriminating by type). Also rename values to featureValues in feature throughout, as values turns out to be a hazardous name in a JS context. Finally use Array instead of Text for array encoding (seems clearer).
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 27 Sep 2016 15:04:59 +0100 |
parents | 8a4bcb3dc3a6 |
children | db17657ac875 |
comparison
equal
deleted
inserted
replaced
65:2d866edd79d5 | 66:6f160dee1192 |
---|---|
94 if (err != "") return {}; | 94 if (err != "") return {}; |
95 | 95 |
96 rr.type = VampJson::getRequestResponseType(j, err); | 96 rr.type = VampJson::getRequestResponseType(j, err); |
97 if (err != "") return {}; | 97 if (err != "") return {}; |
98 | 98 |
99 VampJson::BufferSerialisation serialisation = VampJson::BufferSerialisation::Text; | 99 VampJson::BufferSerialisation serialisation = |
100 VampJson::BufferSerialisation::Array; | |
100 | 101 |
101 switch (rr.type) { | 102 switch (rr.type) { |
102 | 103 |
103 case RRType::List: | 104 case RRType::List: |
104 VampJson::toVampRequest_List(j, err); // type check only | 105 VampJson::toVampRequest_List(j, err); // type check only |
128 Json j; | 129 Json j; |
129 | 130 |
130 VampJson::BufferSerialisation serialisation = | 131 VampJson::BufferSerialisation serialisation = |
131 (useBase64 ? | 132 (useBase64 ? |
132 VampJson::BufferSerialisation::Base64 : | 133 VampJson::BufferSerialisation::Base64 : |
133 VampJson::BufferSerialisation::Text); | 134 VampJson::BufferSerialisation::Array); |
134 | 135 |
135 switch (rr.type) { | 136 switch (rr.type) { |
136 | 137 |
137 case RRType::List: | 138 case RRType::List: |
138 j = VampJson::fromVampRequest_List(); | 139 j = VampJson::fromVampRequest_List(); |
174 if (err != "") return {}; | 175 if (err != "") return {}; |
175 | 176 |
176 rr.type = VampJson::getRequestResponseType(j, err); | 177 rr.type = VampJson::getRequestResponseType(j, err); |
177 if (err != "") return {}; | 178 if (err != "") return {}; |
178 | 179 |
179 VampJson::BufferSerialisation serialisation = VampJson::BufferSerialisation::Text; | 180 VampJson::BufferSerialisation serialisation = |
181 VampJson::BufferSerialisation::Array; | |
180 | 182 |
181 rr.success = j["success"].bool_value(); | 183 rr.success = j["success"].bool_value(); |
182 rr.errorText = j["errorText"].string_value(); | 184 rr.errorText = j["errorText"].string_value(); |
183 | 185 |
184 switch (rr.type) { | 186 switch (rr.type) { |
211 Json j; | 213 Json j; |
212 | 214 |
213 VampJson::BufferSerialisation serialisation = | 215 VampJson::BufferSerialisation serialisation = |
214 (useBase64 ? | 216 (useBase64 ? |
215 VampJson::BufferSerialisation::Base64 : | 217 VampJson::BufferSerialisation::Base64 : |
216 VampJson::BufferSerialisation::Text); | 218 VampJson::BufferSerialisation::Array); |
217 | 219 |
218 if (!rr.success) { | 220 if (!rr.success) { |
219 | 221 |
220 j = VampJson::fromError(rr.errorText, rr.type); | 222 j = VampJson::fromError(rr.errorText, rr.type); |
221 | 223 |