小编Joh*_*est的帖子

如何从JSON文件中的每个值中删除空格和换行符?

我有一个JSON具有以下结构的文件:

{
    "name":[
        {
            "someKey": "\n\n   some Value   "
        },
        {
            "someKey": "another value    "
        }
    ],
    "anotherName":[
        {
            "anArray": [
                {
                    "key": "    value\n\n",
                    "anotherKey": "  value"
                },
                {
                    "key": "    value\n",
                    "anotherKey": "value"
                }
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

现在我想要strip删除JSON文件中每个值的所有空格和换行符.有没有办法迭代字典的每个元素和嵌套的字典和列表?

python json strip

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

json ×1

python ×1

strip ×1