| |||||||||||
PyWeek - The joys of jsonWhat I've discovered so far this week is that json is awesome. For everything. We have it as our map format and we have it for saving settings. With simplejson it is just pure awesomeness. Much easier than ini or any other format.All the json elements convert strait to their python elements equivalent (thanks to javascript and python types having so much in common). I don't have to do any manual type converting from the settings file to python this way. Much better than any ini parsers I've seen. — joey101 on 2008/09/10 18:04 of Arctic Paint: Gondola Comments: (log in to comment) |
Last Challenge
> September 2008 [entries, ratings] Previous March 2008 [entries, ratings] September 2007 [entries, ratings] April 2007 [entries, ratings] September 2006 [entries, ratings] March 2006 [entries, ratings] (June 2006) August 2005 [entries, ratings] Not logged in Login | ||||||||||
By richard on 2008/09/10 21:48:
Why don't you just use Python and execfile to load? :)By joey101 on 2008/09/10 23:05:
I sure hope you speak in jest... :]By RB[0] on 2008/09/11 01:21:
I would have suggested the same actually, or equivalent to it O.oWhy is that a joke in your opinion? LOL.
But actually, looks kinda cool using a different tool outside of the norm - so more power to you :)
BTW - your game screenies look awesome O.o
By joey101 on 2008/09/11 02:38:
Well, for one thing it is horribly insecure. Say you didn't know anything about python and were playing the game (which used executed arbitrary python code to construct maps as richard suggested doing). Then someone gives you a new map; they tell you to just put it in your map directory and play it. The game executes the python map file expecting it to setup the map... but instead wipes your hard drive (python wouldn't normally have the permissions to do that but you get the point).This would greatly inhibit a community from creating content for your game.
Game development is like web development in this respect: never EVER trust any external data to be safe. Security though obscurity never works. (Especially when the code is open source)
Secondly I personally think using code for data structures when something else can be used is just bad practice. For instance it is much more difficult to make a level editor that has to use coded structure format apposed to something like XML, png or json.
By richard on 2008/09/11 04:22:
You didn't mention trust in your original post - in fact you mentioned saving settings. Why can't you trust your own settings? :)By joey101 on 2008/09/11 15:31:
Yes I did mention settings.. but I ALSO mentioned for use as a map format. As far as trust goes I was doing we development years before making games. Executing any external code is a big no-no. Even if it's on your server - if it has the slightest chance of being used how it was not meant to be it's security hole. The habit has stuck for game development for me I guess. To be honest the thought of executing python code for maps, settings or anything else had never even crossed my mind until this message thread.The settings isn't nearly as big of a potential problem as the map format though. But still, it takes more code to reconstruct it for saving than json or ini. Especially json.
By saluk on 2008/09/11 17:23:
Especially when simplejson.load is just as many lines as execfile :) Well, I suppose there is the import and dependancy, but whatever. I love that javascript and python are so similar. It makes it nice when I am forced to write javascript. Although I have to keep remembering the differences, which can be irritating. ("What? I can't do X?")By joey101 on 2008/09/11 17:43:
It is one line for loading both but saving with json is only one line also. A simple example of using it for a settings file: