File tree 1 file changed +4
-10
lines changed
1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change 1
1
import datetime
2
2
import json
3
3
import os
4
+ import collections
4
5
5
6
import pytest
6
7
@@ -23,7 +24,7 @@ def validator(data_json):
23
24
Returns the original json (pass-through)
24
25
"""
25
26
fields = spec ["fields" ]
26
- data = json .loads (data_json )
27
+ data = json .loads (data_json , object_pairs_hook = collections . OrderedDict )
27
28
for k , v in fields .items ():
28
29
if v .get ("required" ):
29
30
found = False
@@ -57,15 +58,8 @@ def validator(data_json):
57
58
data [k ], k
58
59
)
59
60
)
60
- if v .get ("index" ):
61
- index = v .get ("index" )
62
- key = json .loads (
63
- data_json .split ("," )[index ].split (":" )[0 ].strip ().lstrip ("{" )
64
- )
65
- if key != k :
66
- raise ValidationError (
67
- "Key {0} is not at index {1}" .format (k , index )
68
- )
61
+ if v .get ("index" ) and list (data .keys ())[v .get ("index" )] != k :
62
+ raise ValidationError ("Key {0} is not at index {1}" .format (k , index ))
69
63
70
64
return data_json
71
65
You can’t perform that action at this time.
0 commit comments