我有一个json字典,我想删除整个json数据中整数值的引号。你知道吗
[
{
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": "8.0"
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": "90"
}
]
}
]
当我将上述对象传递给一个函数(即
def remove_quote_for_int_values(obj):
print(expected_output_is_below)
pass
上面是我想要实现的json数据,如下所示
[
{
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 90
}
]
}
]
首先,如果整数值表示为字符串,那么这是一个非常奇怪的JSON对象。你知道吗
但您可以执行以下操作:
这两种解决方案也应该适用于嵌套对象。你知道吗
这并不漂亮,可能有一种更简单、更有效的方法,但这是可行的:
输出:
相关问题 更多 >
编程相关推荐