Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Paste JSON As JSDocNew to Visual Studio Code? Get it now.
Paste JSON As JSDoc

Paste JSON As JSDoc

Ryan.Liu

|
151 installs
| (0) | Free
Use for pasting JSON string to JSDoc
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

pastejsonasjsdoc README

A tool for generating JSDoc in JaveScript project.

Features

Add Paste JSON as JSDoc Typedef command for generating JSDoc Typdef comments from JSON string. Example:

step 1: copy JSON string as follows:

 {"a":1, "b":"2" , "c":true, "arr":["str1","str2","str3"]}

step 2: Select a point in your document for inserting comments.

step 3: Press Cmd+Shift+P(for Mac) / Ctrl+Shift+P (for Windows).

step 4: Input > Paste JSON as JSDoc Typedef command and press Enter.

step 5: Input a type name( e.g: IReturnData) and press Enter.

It will generate JSDoc typedef comments as follow:


/**
 * @typedef {object} IReturnData 
 * @property {number} a -  e.g:1
 * @property {string} b -  e.g:"2"
 * @property {boolean} c -  e.g:true
 * @property {Array<string>} arr -  e.g:["str1"]
 */

Than you can use IReturnData type in your JSDoc comments.

/**
 * @type {IReturnData}
 */
 let returnData;


/**
 * @param {IReturnData} data 
 */
function getData(data){
    //...
}

When you want use a 'IReturnData' typedef in other file. You can import it, as follow:

/**
 * @type {import('./xxx/someFileDefineIReturnData').IReturnData}
 */
let data;

Also you can define an alias in other file for avoid to repeate input import("xxx")


/**
 * @typedef {import('./xxx/someFileDefineIReturnData').IReturnData} IReturnData
 */

/**
 * @returns {IReturnData}
 */
function getData() {
    return {xxx};
}


Release Notes

1.0.0 (2022-05-19)

Initial release.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft