From 9c9de11e06c58cbdf008edaeecbc75ca9cbf6bb9 Mon Sep 17 00:00:00 2001 From: "Vu. Le Thanh" Date: Sun, 8 Feb 2015 00:10:47 +0700 Subject: [PATCH] Fix incorrect order in JSON output --- glue/formats/base.py | 2 +- glue/formats/jsonformat.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/glue/formats/base.py b/glue/formats/base.py index 622c91c..32bdcc0 100644 --- a/glue/formats/base.py +++ b/glue/formats/base.py @@ -158,7 +158,7 @@ def needs_rebuild(self): return False def render(self, *args, **kwargs): - return json.dumps(self.get_context(*args, **kwargs)) + return json.dumps(self.get_context(*args, **kwargs), indent=4) class BasePlistFormat(BaseTextFormat): diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index 50085f7..c204fec 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -1,3 +1,4 @@ +from collections import OrderedDict import os import json import codecs @@ -33,7 +34,7 @@ def populate_argument_parser(cls, parser): def get_context(self, *args, **kwargs): context = super(JSONFormat, self).get_context(*args, **kwargs) - frames = dict([[i['filename'], {'filename': i['filename'], + frames = OrderedDict([[i['filename'], {'filename': i['filename'], 'frame': {'x': i['x'], 'y': i['y'], 'w': i['width'], @@ -47,7 +48,7 @@ def get_context(self, *args, **kwargs): 'sourceSize': {'w': i['original_width'], 'h': i['original_height']}}] for i in context['images']]) - data = dict(frames=None, meta={'version': context['version'], + data = OrderedDict(frames=None, meta={'version': context['version'], 'hash': context['hash'], 'name': context['name'], 'sprite_path': context['sprite_path'],