MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / parse

Function parse

app/rcc/scripts/parser/js/json_data.js:50–64  ·  view source on GitHub ↗

* Parses a JSON frame into an array of values. * * @param {string} frame - The JSON data from the data source * @returns {array} Array of values mapped according to fieldToIndexMap

(frame)

Source from the content-addressed store, hash-verified

48 * @returns {array} Array of values mapped according to fieldToIndexMap
49 */
50function parse(frame) {
51 try {
52 let data = JSON.parse(frame);
53 for (let field in fieldToIndexMap) {
54 if (fieldToIndexMap.hasOwnProperty(field) && data.hasOwnProperty(field))
55 parsedValues[fieldToIndexMap[field]] = data[field];
56 }
57
58 return parsedValues;
59 }
60 catch (e) {
61 console.error("JSON parse error:", e.message);
62 return parsedValues;
63 }
64}

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected