MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / traverseJson

Function traverseJson

Extension/gulpfile.js:168–182  ·  view source on GitHub ↗
(jsonTree, descriptionCallback, prefixPath)

Source from the content-addressed store, hash-verified

166
167// descriptionCallback(path, value, parent) is invoked for attributes
168const traverseJson = (jsonTree, descriptionCallback, prefixPath) => {
169 for (let fieldName in jsonTree) {
170 if (jsonTree[fieldName] !== null) {
171 if (typeof (jsonTree[fieldName]) == "string" && (fieldName === "description" || fieldName === "markdownDescription")) {
172 descriptionCallback(prefixPath, jsonTree[fieldName], jsonTree);
173 } else if (typeof (jsonTree[fieldName]) == "object") {
174 let path = prefixPath;
175 if (path !== "")
176 path = path + ".";
177 path = path + fieldName;
178 traverseJson(jsonTree[fieldName], descriptionCallback, path);
179 }
180 }
181 }
182};
183
184// Traverses schema json files looking for "description" fields to localized.
185// The path to the "description" field is used to create a localization key.

Callers 2

processJsonSchemaFilesFunction · 0.85

Calls 1

descriptionCallbackFunction · 0.85

Tested by

no test coverage detected