tools: dry utility function in tools/doc/json.js
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines
Also, move a declaration of unrelated variable closer to its only context.
Generated doc set is identical after this change.