网站导航树作为JSON - 这是不好的做法? [关闭]

I have to implement x-level deep navigation menu for a website. After I spent few hours trying to come up with a good way for storing, manipulating, and displaying this tree, I decided to go with JSON over MySQL. I'd either put it in a file, or in a field in a MySQL (Tho I think it may be an overkill since it is just one row with one field).

I am using jQuery nestable list plugin, and the reason why I'd like to go with JSON is that I can directly manipulate items data as they are DOM elements (which I find much easier than passing ID's and taking care of which elements are for deletion, which should be updated, and which should be added), and get serialized output, save it "as is" in a file, and when it comes to laying it out into horizontal multi-level dropdown menu, I can do it with help of PHP respecting items orders and nesting made by plugin.

Is this bad practice for some reason? Performance wise?

There are some things to be aware of:

1) Storing tree structure using MySQL isn't really that straight-forward

2) But database engine takes care for some elementary locking (think about what happens if two users are writing tree structure to the file at the same exact time)

3) What happens if you serialize and store structure "as is", but html and/or java-script structure changes? Will it still work? Most likely you would have to write a function to convert all serialized data to be compatible with new structure.

4) Performance wise it really doesn't make any difference whether you use json + files / json + mysql / only mysql - those couple of milliseconds won't make any difference. Keep your code logical, readable and easily maintainable - is most cases it is cheaper to upgrade your hardware rather than to maintain and develop "hacky" code.

To sum it up, it seems to be OK to store this kind of data as json, just be aware of some possible problems mentioned above.