Fixed and added test for JSON properties order.

This commit is contained in:
Alexander Nelzin 2014-11-13 23:56:05 +03:00
parent 0481957715
commit a2b12f75ea
2 changed files with 6 additions and 1 deletions

View File

@ -640,7 +640,7 @@ def parse_items(items,
if item.sep in SEP_GROUP_RAW_JSON_ITEMS:
try:
value = json.loads(value)
value = json.loads(value, object_pairs_hook=OrderedDict)
except ValueError as e:
raise ParseError('"%s": %s' % (item.orig, e))
target = data

View File

@ -63,3 +63,8 @@ class TestHTTPie:
assert HTTP_OK in r
assert '"User-Agent": "HTTPie' in r, r
assert '"Foo": "bar"' in r
def test_json_order(self, httpbin):
r = http('PATCH', httpbin.url + '/patch', 'order:={"map":{"1":"first","2":"second"}}')
assert HTTP_OK in r
assert r.json['data'] == '{"order": {"map": {"1": "first", "2": "second"}}}'