简体   繁体   中英

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.

Is this possible? thanks

Yes, this is a perfect application for JSON (Javascript Object Notation). 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"
                }
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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