Jun-11-2018, 07:50 AM
(Jun-10-2018, 06:50 PM)buran Wrote: 1. the way you read the json is not right
with open("con_error.json", "r") as f: data = json.load(f)now you have your json as data dict
2. if use str.replace to replace "null"(?!). what you do is to read json, then immediately dump it back as string. So then why read it as json at all? just read the file as text and replace "null" if you are going to do this
3. once you read the json properly as a dict you can loop over it and replace None. However it looks like complex data structure, so I cannot be more specific
Thank you very much to all for answer my question. I am trying to realize for loop in a dict object , but some values are replace and other no. The code is:
for i, j in data.iteritems(): if j is None: data[i] = 'vacio'i dont understand why no replace all values
Thank you very much!