(jsonTree, descriptionCallback, prefixPath)
| 166 | |
| 167 | // descriptionCallback(path, value, parent) is invoked for attributes |
| 168 | const 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. |
no test coverage detected