在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ChannelIQ/jsoncompare开源软件地址:https://github.com/ChannelIQ/jsoncompare开源编程语言:Python 100.0%开源软件介绍:##Install pip install jsoncompare ##Explanation
Recent Changes
##Examples from jsoncompare import jsoncompare
# Compare respecting each array's order
jsoncompare.are_same(a, b)
# Compare ignoring each array's order
jsoncompare.are_same(a, b, True)
# Compare ignoring the value of certain keys
jsoncompare.are_same(a, b, False, ["datetime", "snacktime"])
# Contains at least
jsoncompare.contains(a, b) # Getting difference traces
from jsoncompare import jsoncompare
a = {
"failureReason" : "Invalid request entity",
"fieldValidationErrors" : [
{
"field" : "normal value 1",
"reason" : "may not be smelly"
},
{
"field" : "Catalog.name",
"reason" : "may not be null"
}
]
}
b = {
"failureReason" : "Invalid request entity",
"fieldValidationErrors" : [
{
"field" : "crazy value 2",
"reason" : "may not be null"
},
{
"field" : "Catalog.catalogOwner",
"reason" : "may not be null"
}
]
}
print jsoncompare.are_same(a, b)[1] results in: Reason: Different values
Expected:
"normal value 1"
Actual:
"crazy value 2"
Reason: Different values (Check order)
Expected:
{
"field": "normal value 1",
"reason": "may not be smelly"
}
Actual:
{
"field": "crazy value 2",
"reason": "may not be null"
}
Reason: Different values
Expected:
[
{
"field": "normal value 1",
"reason": "may not be smelly"
},
{
"field": "Catalog.name",
"reason": "may not be null"
}
]
Actual:
[
{
"field": "crazy value 2",
"reason": "may not be null"
},
{
"field": "Catalog.catalogOwner",
"reason": "may not be null"
}
] |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论