Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualNercury

Posted 28 February 2013 - 02:45 PM

You can store these things in json file ("example.json"):

 

{
	"monsters": [
		{
			"name": "Rabbit",
			"hp": 30,
			"attack": 5
		},
		{
			"name": "Rat",
			"hp": 40,
			"attack": 10
		}
	]
}

 

And load using python JSON library (included in Python 2.6):

 

import json

config_file = open('example.json')
data = json.load(config_file)
config_file.close()

for monster in data["monsters"]:
    print monster

#1Nercury

Posted 28 February 2013 - 02:44 PM

You can store these things in json file:

 

{
	"monsters": [
		{
			"name": "Rabbit",
			"hp": 30,
			"attack": 5
		},
		{
			"name": "Rat",
			"hp": 40,
			"attack": 10
		}
	]
}

 

And load using python JSON library (included in Python 2.6):

 

import json

config_file = open('test.json')
data = json.load(config_file)
config_file.close()

for monster in data["monsters"]:
    print monster

PARTNERS