English 中文(简体)
记录JSON档案结构的最佳做法? [闭门]
原标题:Best practice for documenting a JSON file structure? [closed]
Closed. This question is opinion-based. It is not currently accepting answers.

我希望其他人能够创建我能理解的“智者”档案。 我如何最好地记录所需结构/允许的结构?

例:

{
    "customer1" : {
        "open-orders" : [
            123,
            456
        ],
        "terms" : [
            "net 30"
        ]
    }, ...
}

我怎么说像“第一层”那样,它把客户身份记录在客户关系管理系统中。 然后,这些术语必须存在,并且可能有1至3项。 您永远不会说一层标签错误,但所有其他不知名的标签都被忽视等等。

In XML 我可以使用已经掌握其中一些信息的TDD,我可以补充一些补充意见。

但是,日本人的最佳做法是什么? 我现在用一个表层结构,在左栏中,根据我的结构,有有效的初等人物档案,这些档案被编为平坐,每个都列在桌上。 在右栏中,我当时写的是假话、一张chu/流。 我对此感到不快。 是否有更好的想法?

最佳回答

JSON只是你数据结构的序号;因此,你应记录数据结构,而不是序列产出。

/**
 * @var object Customer
 */
var customer = {
    /**
     * @var Number[][]
     */
    "open-orders": [],
    /**
     * @var String[][]
     */
    "terms": []
};

此外,日本科学研究所没有像XML(XML)这样的数据规格(编号);虽然XML也可用于数据序列,但请你具体说明数据结构(XSD)。 JSON无意这样做,也没有为此提供机制。

问题回答

你可以为json结构写一个图象(如XML档案的一张 d)。

Here s a good place to start: http://json-schema.org

例:

{
    "title": "Example Schema",  
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string"
         },
         "lastName": {
             "type": "string"
         },
         "age": {
             "description": "Age in years",
             "type": "integer",
             "minimum": 0
         }
    },
    "required": ["firstName", "lastName"]
}




相关问题
Logback tutorial [closed]

Where can I find a Logback tutorial and/or sample projects? Something similar with this "Log4j Tutorial" would be nice. Note: I am aware of the documentation available on the official Logback website ...

How to document the Main method? [closed]

Okay, so I ve got a .NET console application with it s Main method, contained in a Program class. You know, the usual: class Program { static void Main(string[] args) { // Do ...

javadoc: show also descriptions of methods from parent class

Is there a way to produce javadoc so that all methods accessible from the class are listed with their full description? Usually only the methods defined in that class are listed and the rest are only ...

Is there a list of known web crawlers? [closed]

I m trying to get accurate download numbers for some files on a web server. I look at the user agents and some are clearly bots or web crawlers, but many for many I m not sure, they may or may not be ...

热门标签