-
Notifications
You must be signed in to change notification settings - Fork 42
Let _make_validate
method supports the list
structures JSON
#18
Conversation
5 similar comments
{"eq": ["content.{}".format(key), value]} | ||
) | ||
if isinstance(resp_content_json, dict): | ||
for key, value in resp_content_json.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(value, (dict, list)):
continue
这一部分还是有必要的,因为假如 value 为 dict/list,已经算是复杂结构体了,保持不变的可能性较小,所以不宜直接将其作为比较项。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
的确,不过目前我这边用的还没有这个问题 😅
) | ||
elif isinstance(resp_content_json, list): | ||
for i in range(0, len(resp_content_json)): | ||
resp_content_json = resp_content_json[i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有两个问题:
1、重复使用 resp_content_json 这个变量名容易产生混淆,建议对 list 的元素采用不同的变量名;
2、你这里假设 list 始终是 [{a:a},{b:b},...]
的形式,那假如出现 [{a:a},b,...]
的情况就会出现问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,想要通用的话,还是要多考虑一下这块,期待后续 validator 支持 jmespath 的语法~~
@asdf2014 我先将这个PR关闭了哈,后面会更新为 jmespath 语法。 |
@debugtalk 嗯呢,期待下 |
No description provided.