How to remove whitespaces and newlines from every value in a JSON file?

后端 未结 3 1916
慢半拍i
慢半拍i 2020-11-29 07:08

I have a JSON file that has the following structure:

{
    \"name\":[
        {
            \"someKey\": \"\\n\\n   some Value   \"
        },
          


        
3条回答
  •  眼角桃花
    2020-11-29 07:38

    Parse the file using JSON:

    import json
    file = file.replace('\n', '')    # do your cleanup here
    data = json.loads(file)
    

    then walk through the resulting data structure.

提交回复
热议问题