Syntax for documenting JSON structure

前端 未结 7 1784
别那么骄傲
别那么骄傲 2021-01-31 01:14

So I\'m trying to document the format of the json returned by an api I am writing against and I\'d like to know if there is any popular format for the documentation of json stru

7条回答
  •  日久生厌
    2021-01-31 01:33

    I'm unsure to why you're trying to document JSON, I can guess your trying to find a consistent way to tell an IDE or a developer the data types on your notation.

    jsdoc (http://jsdoc.sourceforge.net/#usage) might be what your are looking for.

    for example:

    {
       /**
         * Name of author
         * @type String
         */
       "author": null, 
       /**
         * has the author been clicked
         * @type Boolean
         */
       "clicked": null, 
       /**
         * Unix Timestamp of the creation date
         * @type Int
         */
       "created": null
    }
    

    Alternatively if your trying to demonstrate the structure of your data. You could look at YAML (http://www.yaml.org/), it's designed to be a human readable serialisation format which maybe be better suited for documenting your data structure.

    A quick example:

    Author:
      name: String
      clicked: Boolean
      created: Integer
    

提交回复
热议问题