简体   繁体   English

Javascript Object 属性在一个单独的文件中

[英]Javascript Object properties in a separate file

I have a JavaScript object with thousands of properties and what i want if possible is to have these properties in a separate file (lets say a txt) so that the admin of the system will be able to make changes at his will without messing with the code.我有一个 JavaScript object 有数千个属性,如果可能的话,我想要的是将这些属性放在一个单独的文件中(假设是一个 txt),这样系统的管理员就可以随意进行更改而不会弄乱代码。

Is this possible?这可能吗? thanks谢谢

Yes, this is a perfect application for JSON (Javascript Object Notation).是的,这是JSON (Javascript Object 表示法)的完美应用程序。 It allows you to store name/values pairs in a tree structure that acts as a "mini database".它允许您将名称/值对存储在充当“迷你数据库”的树结构中。 It's lightning fast, easy to navigate, and is widely used in may platforms.它快如闪电,易于导航,并广泛用于多种平台。

{
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": ["GML", "XML"]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM