json中的条带化路径空白

问题描述

我有一个大型的json文件,其中包含1000多个条目。该json被送入下游库以进行进一步处理。我正在尝试寻找一种更简单的方法来消除值部分中的所有尾随空白。

{
    "Country": [
        {
            "country_name": "Germany ","country_capital": " Berlin","concept_description": "Germany is also known as Deutschland ","country_cities": [
                "Frankfurt"
            ],"neighbouring_countries": [
                " Belgium","France "
            ],"country_group": "Europe "
        },{
            "country_name": " France ","country_capital": " Paris","concept_description": "Effiel Tower is in paris ","country_cities": [
                " montpellier"
            ],"Spain "
            ],"country_group": "Europe "
        }
    ]
}

我尝试使用String.strip()和列表理解来实现此mylist = [[x.strip() for x in y] for y in mylist]。但是,某些键的值作为列表,有些只是字符串。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)