A. I store tags in a database which are user input.
B. For views, a group of these tags are then fetched with a query and concatenated.
C. I iterated this format and print each tag in the view.
For part B I create a JSON array with the concatenation in the query. But now I’m thinking it might be worthwhile to pick an even more lightweight format than JSON. My reasoning is it would make it simpler to validate the user tags coming into the database.
If I were to choose one delimiter, say , to identify tokens would the only validation needed be disallowing this character for tags?
Why do you think so? More often than not, using JSON simplifies things a lot both on the frontend and the backend because you can do a json_decode in PHP and
just an evalJSON.parse in Javascript and then your JSON data will be translated to native objects in the respective language which you can then manipulate easily. So I would recommend you stick to JSON.