Skip to content Skip to sidebar Skip to footer

Is This Entity Definition Model Too Verbose?

I'm developing video game, and I'd like it to be highly modable. Currently, all my game logic is defined in Python, my engine logic in C++, and my data in XML. I'd like to explain

Solution 1:

Have you considered using json instead of XML? It is less verbose, more readable, and can be converted into a ready-to-use Python data structure:

For example:

import json

x='''{"Field": [{"Name": "health", "Value": 100}, {"Name": "toxicity", "Value": 78}],
    "Name": "life",
    "Class": "hero.attributes.Life"}'''

attribute=json.loads(x)

# {u'Class': u'hero.attributes.Life',
#  u'Field': [{u'Name': u'health', u'Value': 100},
#             {u'Name': u'toxicity', u'Value': 78}],
#  u'Name': u'life'}

And to convert the dict back into json,

attr=json.dumps(attribute)

Post a Comment for "Is This Entity Definition Model Too Verbose?"