Syntax for documenting JSON structure

前端 未结 7 1783
别那么骄傲
别那么骄傲 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:54

    For simple APIs where each JSON chunk is only one or two levels deep, then documenting by showing examples seems to be the common practice.

    However for more complex data models such as yours, I have not seen any good solution. There are some JSON schema proposals, but that seems to go against the spirit of JSON, and seems too heavyweight for your purpose of just documenting.

    Personally, I think your scheme is very good. With a few small extensions to handle optional and alternative sections I think it could be just as expressive as Backus-Naur Form, be very easy to read and understand, and be in keeping with the spirit of JSON. Maybe we can get some momentum behind others to use this "Taycher JSON Grammar Form" (TJGF)!

提交回复
热议问题