Skip to content

Commit ab2be1e

Browse files
committed
fix validation results parser
1 parent 6063201 commit ab2be1e

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/services/LicenseeService.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,33 @@ export default {
197197
return Service
198198
.post(context, path, queryParams)
199199
.then((item) => {
200-
const data = {};
201200
const validationResults = new ValidationResults();
202201

203-
item.property.forEach((property) => {
204-
try {
205-
data[property.name] = JSON.parse(property.value);
206-
} catch (e) {
207-
data[property.name] = property.value;
202+
const parse = (source, data = {}) => {
203+
let handler = data;
204+
const { name, property: properties, list } = source;
205+
206+
if (name) {
207+
if (!handler[name]) {
208+
handler[name] = {};
209+
}
210+
handler = handler[name];
211+
}
212+
213+
properties.forEach((property) => {
214+
handler[property.name] = property.value;
215+
});
216+
217+
if (list) {
218+
list.forEach((listItem) => {
219+
parse(listItem, handler);
220+
});
208221
}
209-
});
222+
223+
return handler;
224+
};
225+
226+
const data = parse(item);
210227

211228
validationResults
212229
.setProductModuleValidation(data.productModuleNumber, data)

0 commit comments

Comments
 (0)